Programming Methods & Algorithms scripts - Top 4 Download

Programming Methods & Algorithms script downloads

Changing a closed over value in a cell

In most languages with closures, it is possible to change a closed-over value and have the change visible in other closures which share a reference to the same variable. Python's syntax makes this impossible. Putting your changeable values inside a mutable object like a list-- it may occasionally happen that you ...
Python

Dictionary Mixin Framework

This script makes it easy to provide a full dictionary interface to a class defining only a few mapping methods for getting, setting, deleting, and listing keys. Also, a function is provided to incorporate the mixin at runtime so that code for existing modules need not be modified.By usmodules nixin as a superclass, ...
Python

Lazy attributes

Lazy attributes script shows how to create attributes with 'computed at first use' values. ...
Python

Classmethod emulation in python2 1

Class methods were introduced in python2.2. This script illustrates how the same effect can be achieved in python 2.1. ...
Python

Yet another Set class for Python

This script is a pure Pythonic implementation of a set class. The syntax and methods implemented are, for the most part, borrowed from PEP 218. ...
Python

Factory pattern

In the factory pattern script you have an object that creates other objects.Factory is useful to separate implementation from interface. It adds a new indirection layer. When you want to instanciate an object you call its factory and the factory creates the instance. ...
Python

Scope qualifier for globals

Scope qualifier for globals script contains the globaliser class that provides a scope qualifier s the glols. ...
Python

Interfaces

Interfaces script deals with the Interface concept in Python. ...
Python

Options management

The goal of this script is to help the use of classes that need a great number of options in constructor for configuration. ...
Python

Just in time instantiation

JIT is a class for Just In Time instantiation of objects. Init is called only when the first attribute is either get or set. Then automatic delegation is used to front for the object. ...
Python

Memento design pattern in python

Memento design pattern in python script allows you to cache instances based on what arguments are passed to them. ...
Python

Simplified attribute accessors using overloading

This script presents an ideom for simplified accessors, that combines typical getter and setter functionality of an attribute into a single overloaded method, that instead of getATTRIBUTE and setATTRIBUTE can now just be called ATTRIBUTE. When called without arguments it acts as a getter and retrieves the attribute's value. When called ...
Python

Tuples with Named Elements via Spawning

Instead of requiring the named attributes list for each instantiation of the tuple, this implementation 'Spawns' a derived tuple class that is taylored to the named attributes specified. And it is this Spawned class that is then used to instantiate tuples. This approach effectively separates the definition of the attribute names from the ...
Python

Quasi Singleton Metaclass

In effect, this script provides a pattern for a set of quasi-singletons, identified by keyword. If no keyword is given, the default share is accessed. ...
Python

Create objects from variable class names

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

A tidy property idiom

This script suggests an idiom for property creation that avoids cluttering the class space with get/set/del methods that will not be used directly. Using thel methods idiom to create properties unnecessarily clutters the class space with get/set/del methods that will not be called directly by users of your class (although, of course, ...
Python

Observer Pattern

This is a Python implementation of the observer pattern. It defines a one-to many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically. ...
Python

Stateful Objects use Mix ins to define behaviour

If you want to implement stateful objects, which have a different set of behaviours according to what state they are in, this requirement can be achieved with the use of mix-ins. A mix-in is a class which is dynamically inherited by an object. The methods of the mix-in class are thus ...
Python

A meta class that provides behavior like Ruby

This script brings a Ruby-like class behavior. When a class is declared, it extends the old class if the class name exists already. ...
Python

ASTVisitor generator

This script parses the online documentation for compiler.ast and generate code for a skeletal ASTVisitor class that includes stubs for all of the various visitNODE functions that you might need in a visitor, along with comments in each function that list that node type's attributes. ...
Python