Programming Methods & Algorithms scripts - Top 4 Download

Programming Methods & Algorithms script downloads

Drawing inheritance diagrams with Dot

Dot is a very nice graph description language developed at MIT. Combined with Python, it makes an ideal tool to automatically generate diagrams. This script produces beautiful inheritance diagrams for Python classes (and metaclasses too). In particular the recipe allows to display the MRO (Method Resolution Order) for complicate inheritance hierarchies. ...
Python

A class keeps a reference to it s instance

This script implements a base class, which allows derived classes to track instances in self.__instances__. It uses a WeakValueDictionary to store instance references. ...
Python

Function emulation using call

This script defines a simple but useful class that emulates a function to gracefully permit latent assignment. In other words, you can use the emulating class as a valid function in assignments with the ability to later associate a function to perform the actual operations. ...
Python

Maintenance free Signals implementation

This is a signals implementation for python. It is similar to the pydispatch module. This implementation enables you to create Signals as members of classes, as globals, or as locals. You may connect any number of functions or class methods to any signal. Connections manage themselves with the weakref module. Signals ...
Python

Auto Incrementer Example of call and yield

This script will automatically return the next integer. It starts with 0. This is an example of how to make a generator and how to make a callable object. ...
Python

Memento Closure

The memento pattern is great for transaction-like processing. This script adds transactional semantics to methods. Methods decorated with @transactional will rollback to entry state upon exceptions. ...
Python

Caching object creation

This script contains many recipes to memoize functions. Using this script you can cache object creation, i.e. __new__ and __init__ methods are called only when n.e. __newt;br >/ ...
Python

Call a function method X times per second

This simple generator function is used to call a function X times per second. ...
Python

Extending Classes

This script contains two implementations for extending an exsisting class using metaclasses. ...
Python

Remove duplicates from a sequence

The fastest way to remove duplicates from a sequence depends on some pretty subtle properties of the sequence elements, such as whether they're hashable, and whether they support full comparisons. This script defines the unique() function that tries three methods, from fastest to slowest, letting runtime exceptions pick the best method available for ...
Python

Composite design pattern using dictionaries

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. ...
Python

Separating Pattern Implementation from Your Code

This script separates pattern implementation from your code so that you can reuse the implementation elsewhere. It is an example that shows a reusable implementation of the Observer pattern. ...
Python

z sync

This script gives access to the Sync class. Objects created by the Sync class are meant to be used when trying to syncronize the execution of two or more threads. ...
Python

Rich Comparison Mixin

This script implements the full suite of rich comparison operators if __cmp__ is defined.The __cmp__ method is sufficient to provide comparisons between user-defined classes. However, inheriting from a base class (such as a builtin) which already provides the rich-comparison methods will cause the derrived __cmp__ not to be used. cause >the/ ...
Python

Right method names suggestion

This script uses __getattr__ to modify the error messages given when a wrong class method is called. It shows the first five ranked most similar method names, followed by the first line of their docstrings (this is useful to see their parameters, if you use this convention in your sources), and ...
Python

A simple date class

This script can be used by anyone who wants a date object for a program. The code was written as a help for someone trying to do the same thing in C . ...
Python

Metaclass Class Policies

This code implements the policy design pattern in Python by using metaclasses and multiple inheritance. ...
Python

Priority queue script

Priority queues are a kind of container that allows specification of the relative order of the data.   ...
Python

unzip

unzip script defines a function that represents the opposite of the zip function used for strings operations. As an alternative you could use the function call zip(zip()). ...
Python

Numeric base converter

This is a traditional base converter with the twist that it accepts any strings as the digits for the input and output bases. Besides all the normal base-converts, you can now create compact versions of huge numbers by converting them to a base that uses all the letters and numbers for ...
Python