Programming Methods & Algorithms Python scripts - Top 4 Download

Programming Methods & Algorithms Python script downloads

Lazy Traversal of Directed Graphs

The os.path.walk routine that ships with the python standard library is limited to traversing the file system tree. This script allows you to realize a generic traversal for arbitrary (directed) graphs with support for recursion limits. ...
Python

New Tail Recursion Decorator

This tail recursion decorator can eliminate the tail calls for recursive functions. ...
Python

Weighted choice

This script uses fact that any probability distributions can be sampled by computing the cumulative distribution, drawing a random number from 0 to 1, and finding the x-value where that number is attained on the cumulative distribution. The searchsorted(..) function performs this search. This script return random samples of cumulative vector ...
Python

Group and partition

This script enables the group_by functionality like the similar function existing in Ruby on Rails. ...
Python

Python Octree Implementation

This script is a simple implementation of an octree data structure in python. Its use is primarily for fast collision or view frustrum culling in interactive 3d environments, but its possible uses are quite open-ended. It was originally written for use with the pyOgre 3d engine binding. The code makes use of ...
Python

A general solution of Eight Queens

This script is a general method to figuren out all solutions of eight queens. Certainly, it can also solve any number of queens. Each solution is a list, and each value of the list represents the column number, at the same time the index of this value represents it's row number. For instance, ...
Python

Computing permutations with duplicates

This script handles duplicate values in a list. It could easily be made a generator, and it does not require recursion. ...
Python

Call a Callback when a Tkinter Text is Modified

This script shows you how to make use of the virtual event that determines to call your own callback. Tkinter Text widget notices when it's modified. ...
Python

Number Format function

This function takes a number (integer or float) and returns a string with the integer portion grouped by thousands and the decimal portion rounded or padded to given number of decimal places. ...
Python

Tkinter moving geometry methods

A common way to create new compound widgets is to inherit Frame, create everything you need inside it and pack this base Frame on your application.This script is an alternative to this method, that sets geometry methods and options from a wiget to another. ...
Python

All k subsets from an n set

This script yields each subset of size k from a super set of size n. There are two methods. The first operates on sets of integers of the form range(n). The seconds operates on arbitrary sets or lists. ...
Python

Print Hook

This class gets all output directed to stdout (e.g by print statements) and stderr and redirects it to a user defined function. ...
Python

Allowing the Python profiler to profile C modules

This script lets you take into account time spent in C modules when profiling your Python code. Normally the profiler only profiles Python code, so finding out how much time is spent accessing a database, running encryption code, sleeping and so on is difficult. Profilewrap makes it easy to profile C ...
Python

Shed Skin

Shed Skin is an experimental Python-to-C compiler. It can convert pure, but implicitly statically typed Python programs into optimized C code. Currently, these programs cannot freely use the Python standard library. ...
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

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

Pythologic Prolog syntax in Python

Some of Python's powerful meta-programming features are used to enable writing Python functions which include Prolog-like statements. Such functions load a Prolog-like database. When coupled with a suitable inference engine for logic databases, this is a way to add logical programming -- the last unsupported major paradigm -- to Python. This ...
Python

Static or Class Methods

This script implements class methods that do not require an object instance. ...
Python

Loose Coupling

The "broadcaster" and "broker" modules enable loose coupling between objects in a running application. ...
Python

Ruby like syntactic sugar

Ruby offers very nice language constructs for loops or for iterating over lists like the following: 5.times { print "Hello World" }. This recipe shows how to implement these features in python. ...
Python