Python Code Snippets

08 January, 2014   

Simple Python IRC bot by Berend.

Open up a text editor, copy & paste the code below. Save the file as: "" and exit the editor.

24 December, 2013   

This can be used to get ARP mac address from a IP address. Remember that MAC addresses are in ARP tables (volatile), that's why a ping is done first. But i don't know if timing between ping call and ARP call is enough to make sense (of pinging).

23 September, 2013   

Convert an IP address to an integer for easier storage. Also, convert an integer back to an IP address.

Python code example for Grid made by the Label with Raised border

11 October, 2012   

Python code example for Grid made by Label and Entry

Python has no equivalent to Java's "super" keyword (so that some part of a method can be delegated to the superclass), but it's easy to get similar convenience despite Python's multiple-inheritance generality.

28 June, 2012   

Function to generate soundex code for any string (usually a name). Conforms to Knuth's algorithm and the common Perl implementation.

The pyperl dist provide an interface to the Perl DBI ( This allow direct access to all the perl supported databases from python. Full documentation of the API from 'perldoc DBI' or the ORA "Programming the Perl DBI" book, by A. Descartes and T. Bunce.

The following are some useful functions to build URLs within a CGI script, for example to send a HTTP redirection header

Sending short text messages with socket datagrams is simple to implement and provides a very lightweight message passing idiom.

Python functions are naturally polymorphic on their arguments, and checking argument types loses polymorphism

04 December, 2011   

This snippet represents a simple deserializer of some basic Python types.

04 December, 2011   

Example of If Statement in python

18 August, 2011   

The example Python code to Rotate sequences left or right

The example below shows how to produce a png image from python code, but pygments supports lexers for many other languages and its formatter classes can produce other image formats too. The ImageFormatter class allows to set various parameters of the resulting images.

04 July, 2011   

Here are the Python code Checkbox menu

04 July, 2011   

Animation with threads by John E. Grayson