Programming Methods & Algorithms Python scripts - Top 4 Download

Programming Methods & Algorithms Python script downloads

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

List and dictionary observer

This script implements an observer pattern for dictionaries and lists. It does not support a one-many relation. The observer is sent enough information so that the change can be undone. ...
Python

Implementing Future s with decorators

This script shows you how to kick off a slow process without waiting around for the result. The process is run in the background until the value is actually needed at which time it blocks until the value is ready. ...
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

Pipe convenience function for doing pipes

This script allows that arbitrary number of commands to be strung together with each one feeding into the next ones input. ...
Python

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

Automatic indentation of output

This script is an output stream wrapper; possibly useful for debugging code with print statements. When write() is called, it makes a note of the calling frame. The indentation level is equal to the number of frames in the call stack which have been previously noted. ...
Python

Terminating a subprocess on Windows

The new subprocess module in Python 2.4 allows access to the handle of any newly created subprocess. You can use this handle to terminate subprocesses using either ctypes or the pywin32 extensions. ...
Python

A queue for string data

This script is a queue data structure, for string data only, which looks like a File object. This class takes care of the list.append and .join mess, which is needed for fast string concatenation. ...
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

Lock NT via screensaver

Lock NT via screensaver code implements a Python solution for locking a workstation via a secure screensaver. ...
Python

List iterator with advance and regress

The basic iterator for a list doesn't allow one to skip forward (except with "continue"), or backward (at all), nor does it behave well if the list is modified while it is being traversed. This script is NOT the be-all and end-all of improved iterators, but it gives a few ideas of how a ...
Python

Read write object for pkg config files

The PkgConfig class is useful by itself. It allows reading and writing of pkg-config files. This file, when executed, will read a .pc file and print the result of processing. The result will be functionally equivalent, but not identical. Re-running on its own output should produce identical results. ...
Python

Deque collection class

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

Priority queue script

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

Network Of Linked Dictionaries

Linked dictionaries are dictionaries that can refer to other dictionaries (its bases), similar to class hierarchies, but built at runtime. In this script  a linked dictionary shows all the key/value pairs that are defined locally (in the very instance) and globally (in other linked bases). ...
Python

Case insensitive Dictionary

Case-insensitive Dictionary script is a dictionary that has case-insensitive keys. An internal dictionary maps lowercase keys to (key,value) pairs. All key lookups are done against the lowercase keys, but all methods that expose keys to the user retrieve e lowercanal keys. ...
Python

Ensuring a name definition in a module namespace

This script ensures that a name exists in a target namespace. If it does not, make it available in the target namespace using the given definition. The target should be a namespace dictionary (presumably for a module, see the discussion below otherwise). The default target is __builtins__ (specificially, __builtins__.__dict__). ...
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

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