Programming Methods & Algorithms Python scripts - Top 4 Download

Programming Methods & Algorithms Python script downloads

Create an account in MS active directory

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

Credit card validation

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

Encoding A String

The main purpose of these functions are to allow encoding a string from base 256 to a special base 255. The function view the strings as numbers and simply change what base they are written in. This is not recommended for very long strings; otherwise, the encoding and decoding process can ...
Python

Finding the value passed to a function by name

Sometimes inside a decorator that creates a function with a generic (*args, **kwargs) signature, you want to access a value passed for a particular parameter name to a wrapped function, but don't know whether that value will be passed as a positional or keyword argument, or whether the wrapped function defines ...
Python

Tracking file requests in web server access logs

This script helps you to find out how often and by who a particular file is being requested. It prints the requesting addresses, hostnames, access times, and hit counts. ...
Python

Real class methods in Python

This script demonstrates 'real' class methods, like they are known from Smalltalk. Class methods implicitely receive the actual class as the first parameter. They are inherited by subclasses, and may as well be overridden. Class methods may return anything, although they are particularly useful as constructing, althbr >/ ...
Python

Simpler item retrieval using tupled subscripting

This script shows a small addition to the tuple, list, and dictionary classes to allow for a simpler way to retrieve a number of independent items. By allowing for the subscripting to use tuples some very annoying cases becomes much simpler. This script is suitable for large data sets where you need alot of ...
Python

Simple multiline interactive interpreter

This script is a simple embedded multiline python interpreter built around raw_input(). It interrupts the control flow at any given location with 'exec prompt' and gives control to the user. Allways runs in the current scope and can even be started from the pdb prompt in debugging mode.It was tested with python, jython ...
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

Clean implementation for Ordered Dictionary

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

Flexible enumerate

Flexible enumerate() script adds an additional start argument to the built-in enumerate function. ...
Python

Automated swigging for creating C shared modules

This script contains a simple python function to automate using the swig process for creating C modules for use inside Python. ...
Python

Trace expressions and comments in debug mode

This script acts like a stepping debugger to diagnose and fix your programs. It contains functions for log state and execution flow. ...
Python

Graph Script

This script allows you to create a directed Graph container that can be useful for the collections module. To show its basic API, a complete implementation is available. Many different graph implementations are possible, but this is flexible, fast and simple enough. ...
Python

Pseudo random string to float conversion

Pseudo-random string to float conversion script converts strings to floats in the range [0, 1), using a hash function. ...
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

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

Readable switch construction

Python's lack of a 'switch' statement has garnered much discussion and even a PEP. The most popular substitute uses dictionaries to map cases to functions, which requires lots of defs or lambdas. While the approach shown in this script may be O(n) for cases, it aims to duplicate C's original 'switch' functionality ...
Python

Solving the Metaclass Conflict

Any serious user of metaclasses has been bitten at least once by the infamous metaclass/metatype conflict. This script contains a general recipe to solve the problem, as well as some theory and some examples. ...
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