© Copyright 2000-2015 Source Code Online. Free Source Code and Scripts Downloads.
|Code Listing by Jan Kaliszewski|
A simple implementation of a dictionary which always (when applicable) returns keys, values, items (key-value pairs) sorted by keys (inserting/removing order doesn't matter and only keys are important; so please note that it is something different than OrderedDict in Python 3.1/2.7 or Django's SortedDict).
This module provides an easy way to define and use your own around/before/after auxiliary methods, similar to those used in CLOS (Common Lisp Object System).
My approach to that common issue focuses on efficiency and elegant, declarative style of definition. That's why:
The way switches work is based on unwrapped defaultdict/list lookup.
The way you define switches is based on...
A Python 2.x/3.x-compatibile multiprocess-safe logging file-handler (logging.FileHandler replacement, designed for logging to a single file from multiple independent processes) together with a simple interprocess recursive lock -- universal...
A quick fcntl.flock(fcntl.LOCK_EX | fcntl.LOCK_NB) call sampling script: with one file object (and descriptor) or separate file objects (and different descriptors) pointing to the same filesystem path -- with/without threading or forking.
Just import, call and log your selected call/return/exception/etc. events.
You can use a standard Python logger from the logging module.
Quite flexible tool and about 50 efective SLOC only (excluding the example script).
If you need
to define named tuple subclasses (including reusable abstract ones), adding/overriding some methods, in a convenient way;
to have the named tuple ABC (abstract base class) for isinstance/issubclass tests;
All files and free downloads are copyright of their respective owners. We do not provide any hacked, cracked, illegal, pirated version of scripts, codes, components downloads. All files are downloaded from the publishers website, our file servers or download mirrors. Always Virus check files downloaded from the web specially zip, rar, exe, trial, full versions etc. Download links from rapidshare, depositfiles, megaupload etc not published.