This script allows you to record the order in which items are added. This implementation uses much less code than the others by extending not well-known class DictMixin. ...
The script illustrates the composite design pattern by using hierarchical dictionaries. It can be used to process hierarchical, tree-based data structures using Python dictionaries. ...
The script demonstrates the use of SETs in Python. There is a key object that has constellations already identified and a stars object that contains the stars in the sky. Keys are used to unlocks the stars and the results are printed out for the user of the program. ...
This code uses the constraint package to solve sudoku puzzles. It's designed to be flexible and tested with 9x9 puzzles with 1-9 as possible values. In theory it should be able to solve puzzles of different sizes comprised of letters or symbols instead of numbers. Requirements: · constraint package ...
This script is a module for manipulating WinNT, Win2k & WinXP services. It contains the WService Class. The WService Class is used for controlling WinNT, Win2k & WinXP like services. Just pass the name of the service you wish to control to the class instance and go from there. For example, ...
In Win32 often you'll find time stored in 100-nanosecond intervals since January 1, 1600 UTC. It is stored in a 64-bit value which uses 2 32 bit parts to store the time. The following script is a function that returns the time in the typical format the python time libraries use (seconds ...
This script returns the convex hull (separated into upper and lower chains of vertices) and the diameter (farthest pair of points), given input consisting of a list of 2d points represented as pairs (x,y). The convex hull algorithm is Graham's scan, using a coordinate-based sorted order rather than the more commonly ...
The "CookieInfo" and "Cookie" classes provide developers with an read-only interface to the "cookies.txt" that most browsers store. The CookieInfo class makes Cookie objects from the cookie file. It also provides methods to operate on the whole set of Cookies. The Cookie object provides methods to convert a cookie into both ...
This script contains the basic code to create an account in active directory that shows how to do things like set your own exension attributes, force a reset of the password when the user logs in, and set the home directory. It makes used of python's excellent COM support in win32com. ...
Sometimes you would want to create objects from various classes based on some condition (without using eval()). For example when parsing X(HT)ML files you want to handle some tags using specific classes. This script is an example in this sense. ...
This script implements in python an industry standard algorithm for credit card validation. It works on all major credit cards. You pass in the credit card number as a string and it returns 1 for a valid card or 0 for an invalid card ...
This module provides a simple criteria-based priority queue with "priority cascading".The criteria argument should be a sequence of callables that return boolean values. There is no need to add an "all pass" criterion at the end; the queue will add all non-matching items with the least priority.ill add >a ...
This script is a class to allow programmers to curry functions, so that arguments can be supplied one at a time instead of all at once. E.g., if F = Curry(lambda a,b: a b), then F(1,2) == F(1)(2). ...
Since Python 2.2 there is a handy function in the Garbage Collection Module called get_objects(). It gives back a list of all objects that are under control of the Garbeage Collector. This script implements a way you can extract informations of your application in runtime.The example dumps a list of all ...
This script allows a user to place debug messages, error messages and standard messages throughout a program. The function name and line number will be added to each debug and error message before it is printed out. In addition, each of these messages can be passed to multiple handler objects that can ...
This script is a pure python drop in replacement for collections.deque(). It uses a dictionary as the underlying data structure for the deque (pronounced "deck", short for "double-ended queue", a generalization of stacks and queues) which provides O(1) performance for appends and pops from either end. ...