Python on the web: How to get a list of all available Python modules

If you want to get a complete list of Python modules available on your web host, you can do so with the following code: #!/usr/bin/python import os print “Content-type: text/html\n\n”; print “<html><head></head>” print “<body bgcolor=’#ffffff’>” print “\n<BR><b>Available Modules:</b><BR>” # List all installed packages print ‘<ul>’ dist_list = [] for dist in __import__(‘pkg_resources’).working_set: dist_list.append(dist.project_name.replace(‘Python’, ”).strip()) dist_list … Continue reading Python on the web: How to get a list of all available Python modules

Python: How to print function details iteratively using inspect and getmembers

As described in a previous post, the help() function is great for seeing details about any given module function, one at at time. Python: How to use the built-in help( ) and dir( ) functions For example: print help(imageio.mimsave) However, sometimes we want to see details for all of the functions in an imported module. … Continue reading Python: How to print function details iteratively using inspect and getmembers

Processing.py: How to create grid square patterns and digital camo

Continuing the Processing.py series, this article demonstrates how to use a slight variant of the 10 PRINT example to build a grid pattern design made up of squares of differing sizes and colors. This technique can also produce digital camo (camouflage) patterns! For the previous entry in the Processing.py series, see this page: Processing.py: How … Continue reading Processing.py: How to create grid square patterns and digital camo

Processing.py: How to implement 10 PRINT

Continuing the Processing.py series, this article demonstrates how to implement ’10 PRINT’ to create interesting line images. 10 PRINT is an old Commodore 64 one-line program written in┬áBASIC that looks like this: 10 PRINT CHR$(205.5+RND(1)); : GOTO 10 For more information, see 10print.org. For the previous entry in the Processing.py series, see this page: Processing.py: … Continue reading Processing.py: How to implement 10 PRINT

Processing.py: How to use shapes, placements, and colors

To continue the series of how to use Processing.py, this article demonstrates how to use basic shapes, placements and colors. For the previous entry in the Processing.py series, see this page: Processing.py: How to draw lines and use mouse events This code demonstrates the use of lines, rectangles, ellipses, colors and placements by sketching a … Continue reading Processing.py: How to use shapes, placements, and colors

Processing.py: How to draw lines and use mouse events

Building on the first post about using Processing.py (shown in the table below), this post will demonstrate the basic structure of a Processing.py program, how to draw lines, and understand some other basics of the Processing.py programming language. For the previous entry in the Processing.py series, see this page: Processing.py: Getting Started Example 1: Drawing … Continue reading Processing.py: How to draw lines and use mouse events

Processing.py: Getting Started

Getting started with processing.py, this article follows the instructions found here: http://py.processing.org/tutorials/gettingstarted/ The first step is to download the processing IDE here. Once downloaded create a “processing_py” folder on your desktop and drag the “processing-3.3.6” folder from the .zip into the new folder. Inside this folder, click the processing.exe file and the IDE will open. … Continue reading Processing.py: Getting Started

Python: Using requests to get web page source text

In addition to getting page lengths and status codes using the request method: Python: Using requests to get web page lengths and status codes You can also use requests to return the source code of web pages. For example: import requests sites = [ ‘http://www.python.org’, ‘http://www.jython.org’, ‘http://www.pypy.org’, ‘http://www.drudgereport.com’, ‘http://www.phys.org’, ‘http://www.bluegalaxy.info’, ‘http://www.bluegalaxy.info/codewalk’ ] for url in … Continue reading Python: Using requests to get web page source text

Python: Using requests to get web page lengths and status codes

With Python 3.6 and the requests module, it is easy to read data from the web. Here are a couple of basic things we can do with the requests module. Getting a Status code import requests r = requests.get(‘http://www.bluegalaxy.info’) print( r.status_code ) Which yields: 200 For more information about HTTP status codes, there are multiple … Continue reading Python: Using requests to get web page lengths and status codes