Programming Methods & Algorithms scripts - Top 4 Download

Programming Methods & Algorithms 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

Rabin Miller probabilistic prime test

In this script is included a method for performing the Rabin-Miller probabilistic test for a composite witness.  Rabin-Miller test can only tell us if a value is definitely composite. In the case where a test value is not a witness for the compositeness of a potential prime, it can only lie with a probability ...
Python

Binary search in one line

This is an implementation of the binary search algorithm in (almost) one line. Given a number 'n' and a list 'L', the function returns the index of the number on the list, or -1. ...
Python

PyCrash

PyCrash is a Run-Time Exception Dumper which handles uncaught exceptions during the execution of Python programs and collects information about the program context. PyCrash can be very useful in report bug information, because the programmer can easily analyse the program execution context of the crashed application. PyCrash provides you following informations: ...
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

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

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

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

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

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

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

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

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

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