This script allows you to do true immutable symbolic enumeration with qualified value access. Most propoqualifiedor an enum in python attempt to solve the issue with a single class. However, fact is that enum has a dual nature: It declares a new anonimous type *and* all possible instances (values) of that ...
This script eliminates completely rounding errors and loss of significance due to catastrophic cancellation during summation. It achieves exactness by keeping full precision intermediate subtotals. Offers three alternative approaches, each using a different technique to store exact subtotals. ach >using/ ...
When you create a Python module, you can use a test script wich import your module. But you probably have noticed that when you run the test script, it always use the first version of your module even if you made changes in the code.This is because the import statement check ...
This script takes a decimal number, converts it into binary, takes the first six numbers in that, converts that into a decimal number, and from there makes it a letter("m") according to the base64 code. ...
This script contains a function that allows you to easily sort a list by multiple columns in ascending and descending order similar in function to the ORDER BY clause in SQL. ...
Built-in "sum" function, as well as add.reduce functions in Numeric/numarray introduce a large error when summing large arrays of like elements. This script contains a function that makes sums with error less than 1e-15. It doesn't use any additional memory (although it destroys the data array), and also runs asymptotically faster for unlimited precision ...
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. ...
The datetime module only accepts inputs of time it understands. For example, the months given to it have to be in range of values 1-12. This wrapper works around that issue and enables you to move forward or backward more arbitrary units of time. It does that by changing the year, ...
This simple decorator is different to other memoize decorators in that it will only cache results for a period of time. It also provides a simple method of cleaning the cache of old entries via the .collect method. This will help prevent excessive or needless memory consumption. ...
A basic time profiler script provides a very simple time profiling module which helps you to measure actual execution time for blocks of Python code. ...
This script will display a hex dump of the disk specified on the command line. As the last two arguments, the program takes the first sector and last sector that should be displayed by this utility. The size of the sectors is stored in a variable created right after the imports ...
In Win32 often you'll find time stored in 100-nanosecond intervals since January 1, 1600 UTC. It is stored in a 64-bit value which uses 2 32 bit parts to store the time. The following script is a function that returns the time in the typical format the python time libraries use (seconds ...
This is a python script very loosely approximating pkill that is a Linux command: will send the specified signal (by default SIGTERM) to each process instead of listing them on stdout. ...
This code converts variables which is made with upper-leters only, into constants at compile time, if it is possible to be replaced. and generate .pyc file. This script is oriented to the compile time evaluation decreasing, the feature of Constants. ...