python Syntax
Please support our Python advertiser: Programming Forums
using 2to3
this is code that thanks to vegaseat helped me convert my programs into python30 (View Snippet)
Set the Desktop Background
This is a simple program and all it does is fiddle with the registry and set the value of the desktop background to be the bmp file that you supply in the function. There are other things you can do with the windows registry, this is just one of the easy things that demonstrates how it all... (View Snippet)
Find pediodicity in a list
A brute force method.
Finds the FIRST and SHORTEST periodicity in the input list. (View Snippet)
A cached property decorator.
This snippet defines a cachedProperty decorator. A cached property differs from a property in that it's value is only computed the first time that the property is accessed and then stored in the object's dict for later use. If the object's attribute is explicitely deleted, it will be computed again... (View Snippet)
A string filtering function based on patterns.
This snippet defines a function patfilter(pattern, rule, sequence) which implements filtering a sequence of strings according to various criteria. The output is either a subsequence of strings, or a sequence of match objects. (View Snippet)
A class for menu based terminal applications.
Many threads in daniweb's python forum deal with menu based programs which run in a terminal. This snippet defines a handy class, MenuCrawler, to help writing such programs. Subclassing from this base classes and adding methods corresponding to a given set of menus allows one to build the... (View Snippet)
A Print function for different versions of python
This snippet defines a Print function which can be used with python 2.4, 2.5, 2.6 and 3.0 (for 3.0 this is just the built-in print function). It's interface is that of the python 3.0's print. It simplifies the task of writing transitional code which runs under python 2.5 and python 3.0. (View Snippet)
Piecewise linear continuous functions.
Joining together ordered sample points (xi, yi) when ths xi's are different yields a piecewise linear continuous (P1) function. This snippet defines a handy class to manipulate these functions. It allows
computing the value and the slope of the function at each point, arithmetic operations,... (View Snippet)
Grouping strings by prefixes
This snippet defines a class which can group a collection of strings according to a given set of prefixes. Each string goes in the group of the longest prefix it contains. (View Snippet)
Mendeleiev's periodic table in python
This snippet allows your code to use the Mendeleiev's periodic table of elements. It defines a single function mendeleiev_table() which returns the table as a python list of lists. (View Snippet)


