CARVIEW |
Select Language
HTTP/2 302
server: nginx
date: Sat, 19 Jul 2025 19:46:47 GMT
content-type: text/plain; charset=utf-8
content-length: 0
x-archive-redirect-reason: found capture at 20090206224859
location: https://web.archive.org/web/20090206224859/https://code.activestate.com/feeds/langs/python/
server-timing: captures_list;dur=0.766801, exclusion.robots;dur=0.031643, exclusion.robots.policy;dur=0.014095, esindex;dur=0.016432, cdx.remote;dur=7.215144, LoadShardBlock;dur=122.397894, PetaboxLoader3.datanode;dur=93.141180
x-app-server: wwwb-app222
x-ts: 302
x-tr: 166
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
set-cookie: SERVER=wwwb-app222; path=/
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
HTTP/2 200
server: nginx
date: Sat, 19 Jul 2025 19:46:47 GMT
content-type: application/atom+xml
content-length: 19912
x-archive-orig-date: Fri, 06 Feb 2009 22:47:17 GMT
x-archive-orig-server: Apache/2.2.3 (CentOS)
x-archive-orig-content-length: 19912
x-archive-orig-expires: Fri, 06 Feb 2009 22:57:17 GMT
x-archive-orig-vary: Cookie
x-archive-orig-last-modified: Fri, 06 Feb 2009 22:47:17 GMT
x-archive-orig-etag: a75eaac4ddad60005f39984ccdd7ec46
x-archive-orig-cache-control: max-age=600
x-archive-orig-age: 102
x-archive-orig-via: 1.0 box19.activestate.com:3129 (squid/2.6.STABLE6)
x-archive-orig-connection: close
cache-control: max-age=1800
x-archive-guessed-content-type: text/xml
x-archive-guessed-charset: utf-8
memento-datetime: Fri, 06 Feb 2009 22:48:59 GMT
link: ; rel="original", ; rel="timemap"; type="application/link-format", ; rel="timegate", ; rel="first memento"; datetime="Wed, 13 Aug 2008 15:40:56 GMT", ; rel="prev memento"; datetime="Mon, 26 Jan 2009 08:14:00 GMT", ; rel="memento"; datetime="Fri, 06 Feb 2009 22:48:59 GMT", ; rel="next memento"; datetime="Mon, 16 Feb 2009 19:02:54 GMT", ; rel="last memento"; datetime="Fri, 28 Jun 2024 22:06:13 GMT"
content-security-policy: default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob: archive.org web.archive.org web-static.archive.org wayback-api.archive.org athena.archive.org analytics.archive.org pragma.archivelab.org wwwb-events.archive.org
x-archive-src: 52_8_20090206223807_crawl101-c/52_8_20090206224552_crawl103.arc.gz
server-timing: captures_list;dur=1.332724, exclusion.robots;dur=0.048233, exclusion.robots.policy;dur=0.021258, esindex;dur=0.032065, cdx.remote;dur=13.484271, LoadShardBlock;dur=111.882165, PetaboxLoader3.datanode;dur=75.080751, PetaboxLoader3.resolve;dur=139.232229, load_resource;dur=185.219644
x-app-server: wwwb-app222
x-ts: 200
x-tr: 349
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
accept-ranges: bytes
ActiveState Code: Python recipes https://code.activestate.com/recipes/langs/python/ 2009-02-06T07:06:06Z Recently added Python recipes Diff Two Dictionaries (Python)
2009-02-05T08:35:07Z Michael Shepanski https://ActiveState%20Code/recipes/users/4169100/ https://code.activestate.com/recipes/576644/
<p style="color: grey">
Python
recipe 576644
by <a href="/recipes/users/4169100/">Michael Shepanski</a>
(<a href="/recipes/tags/dictionary/">dictionary</a>, <a href="/recipes/tags/diff/">diff</a>, <a href="/recipes/tags/difference/">difference</a>).
</p>
<p>Diff two dictionaries returning just the differences. If an item is not found, it is represented by the string "<KEYNOTFOUND>". If there is a better way, please share. :)</p>
Recursive file/folder cleaner (Python)
2009-02-06T07:06:06Z Alia Khouri https://ActiveState%20Code/recipes/users/4169084/ https://code.activestate.com/recipes/576643/
<p style="color: grey">
Python
recipe 576643
by <a href="/recipes/users/4169084/">Alia Khouri</a>
(<a href="/recipes/tags/cleaner/">cleaner</a>, <a href="/recipes/tags/files/">files</a>).
Revision 13.
</p>
<p>This script recursively scans a given path and applies a cleaning 'action' to matching files and folders. By default files and folders matching the specified (.endswith) patterns are deleted.</p>
<p>It is designed with simplicity, extensibility, portability, class-based and commandline usage, and most importantly, permission-based operations in mind: i.e. it tells you what files/folders are going to be affected and asks your permission to proceed.</p>
<p>It is also very easy to extend with more intelligent pattern matching (e.g regexes, glob patterns) and other path operating cleaning functions. For convenience, one should place the script in your path and call it something like 'clean':</p>
<pre><code>Usage: clean [options] patterns
deletes files/folder patterns:
clean .svn .pyc
clean -p /tmp/folder .svn .csv .bzr .pyc
converts line endings from windows to unix:
clean -e .py
clean -e -p /tmp/folder .py
Options:
-h, --help show this help message and exit
-p PATH, --path=PATH set path
-n, --negated clean everything except specified patterns
-e, --endings clean line endings
-v, --verbose
</code></pre>
DBM with Dict-speed accesses and Multiple standard file formats (Python)
2009-02-05T17:12:01Z Raymond Hettinger https://ActiveState%20Code/recipes/users/178123/ https://code.activestate.com/recipes/576642/
<p style="color: grey">
Python
recipe 576642
by <a href="/recipes/users/178123/">Raymond Hettinger</a>
.
Revision 5.
</p>
<p>dbdict: a dbm based on a dict subclass.</p>
<p>On open, loads full file into memory.
On close, writes full dict to disk (atomically).
Supported output file formats: csv, json, and pickle.
Input file format automatically discovered.</p>
<p>Usable by the shelve module for fast access.</p>
Remove the .pyc files from current directory tree and from svn (Python)
2009-02-03T23:38:43Z Senthil Kumaran https://ActiveState%20Code/recipes/users/4165833/ https://code.activestate.com/recipes/576641/
<p style="color: grey">
Python
recipe 576641
by <a href="/recipes/users/4165833/">Senthil Kumaran</a>
(<a href="/recipes/tags/parsing/">parsing</a>).
</p>
<p>I had mistakenly checked in .pyc files into svn, So I took this approach of deleting all the .pyc files in the current working copy directory tree and then using svn remove to the remove from the repository. The following is the snippet I wrote then to for the purpose.</p>
Prime Number Generator (Python)
2009-02-03T15:47:06Z dth https://ActiveState%20Code/recipes/users/4169078/ https://code.activestate.com/recipes/576640/
<p style="color: grey">
Python
recipe 576640
by <a href="/recipes/users/4169078/">dth</a>
(<a href="/recipes/tags/Eratosthene/">Eratosthene</a>, <a href="/recipes/tags/generator/">generator</a>, <a href="/recipes/tags/number/">number</a>, <a href="/recipes/tags/of/">of</a>, <a href="/recipes/tags/prime/">prime</a>, <a href="/recipes/tags/Sieve/">Sieve</a>).
Revision 7.
</p>
<p>Generate all prime numbers up to n.</p>
Percent -> Logit Transformation (Python)
2009-02-02T00:47:10Z donyo Ganchev https://ActiveState%20Code/recipes/users/4167704/ https://code.activestate.com/recipes/576639/
<p style="color: grey">
Python
recipe 576639
by <a href="/recipes/users/4167704/">donyo Ganchev</a>
.
</p>
<p>Convert percent effectiveness to logit</p>
Draft for an sqlite3 based DBM (Python)
2009-01-30T10:27:30Z Raymond Hettinger https://ActiveState%20Code/recipes/users/178123/ https://code.activestate.com/recipes/576638/
<p style="color: grey">
Python
recipe 576638
by <a href="/recipes/users/178123/">Raymond Hettinger</a>
.
Revision 4.
</p>
<p>Makes shelves viable again in 3.0. Still a work in progress.</p>
Round to base (Python)
2009-01-28T09:48:13Z David Lambert https://ActiveState%20Code/recipes/users/4167420/ https://code.activestate.com/recipes/576637/
<p style="color: grey">
Python
recipe 576637
by <a href="/recipes/users/4167420/">David Lambert</a>
.
</p>
<p>This python3 code generalizes rounding. It includes a "base" argument, which can be a float greater than 0. The "number of places" argument may also be a float. When the base is 10 Round uses builtins.round.</p>
Paratessares Time (Python)
2009-01-27T18:43:51Z Stephen Chappell https://ActiveState%20Code/recipes/users/2608421/ https://code.activestate.com/recipes/576636/
<p style="color: grey">
Python
recipe 576636
by <a href="/recipes/users/2608421/">Stephen Chappell</a>
(<a href="/recipes/tags/3.0/">3.0</a>, <a href="/recipes/tags/Paratessares/">Paratessares</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/Tessaressunago/">Tessaressunago</a>, <a href="/recipes/tags/time/">time</a>).
Revision 3.
</p>
<p>This module provides several functions that covert earth seconds into paratessares time. It is used to implement time keeping on a fictional planet and is the standard time system of Tessaressunago. It can be used as an inspiration to other people creating their own units of time or as partitioned timestamps that can be applied to records. There are four different modules listed below: the standard implementation, a unit test, and two examples. To see the Python 2.5 version of this code in action and to test out its functionality, you can go over to the Utility Mill and find Paratessares_Time in the library ( <a href="https://utilitymill.com/utility/Paratessares_Time" rel="nofollow">https://utilitymill.com/utility/Paratessares_Time</a> ).</p>
whois (Python)
2009-01-26T17:43:31Z Ryan Ozmun https://ActiveState%20Code/recipes/users/4168990/ https://code.activestate.com/recipes/576635/
<p style="color: grey">
Python
recipe 576635
by <a href="/recipes/users/4168990/">Ryan Ozmun</a>
(<a href="/recipes/tags/network/">network</a>, <a href="/recipes/tags/whois/">whois</a>).
Revision 2.
</p>
<p>Simple whois client</p>
Control CPU Usage by using ctypes (Win32 Platform) (Python)
2009-01-26T09:32:34Z Shao-chuan Wang https://ActiveState%20Code/recipes/users/4168519/ https://code.activestate.com/recipes/576634/
<p style="color: grey">
Python
recipe 576634
by <a href="/recipes/users/4168519/">Shao-chuan Wang</a>
(<a href="/recipes/tags/CPU Usage/">CPU Usage</a>, <a href="/recipes/tags/ctypes/">ctypes</a>, <a href="/recipes/tags/System Programming/">System Programming</a>, <a href="/recipes/tags/Win32/">Win32</a>).
Revision 3.
</p>
<p>This program will make your cpu work at a given cpu usage. It should be also able to work on machines with multi-processors. The program has been tested on Windows xp sp2 with python of version 2.5.4.</p>
<p>The implementation is based on the fact that it will adjust the ratio of being busy over being idle in the main process to approach the target cpu usage rate. </p>
Stacked graphs using matplotlib (Python)
2009-01-26T08:11:59Z Anand Patil https://ActiveState%20Code/recipes/users/4168675/ https://code.activestate.com/recipes/576633/
<p style="color: grey">
Python
recipe 576633
by <a href="/recipes/users/4168675/">Anand Patil</a>
(<a href="/recipes/tags/broadband/">broadband</a>, <a href="/recipes/tags/matplotlib/">matplotlib</a>, <a href="/recipes/tags/mobile/">mobile</a>, <a href="/recipes/tags/stacked graph/">stacked graph</a>, <a href="/recipes/tags/stream graph/">stream graph</a>).
</p>
<p>Creates stacked graphs (sometimes known as stream graphs, apparently) as recommended by Byron and Wattenberg, <a href="https://www.leebyron.com/else/streamgraph/download.php?file=stackedgraphs_byron_wattenberg.pdf" rel="nofollow">https://www.leebyron.com/else/streamgraph/download.php?file=stackedgraphs_byron_wattenberg.pdf</a></p>
Queue with tagged items (Python)
2009-01-28T07:23:40Z Jirka Vejrazka https://ActiveState%20Code/recipes/users/4168986/ https://code.activestate.com/recipes/576632/
<p style="color: grey">
Python
recipe 576632
by <a href="/recipes/users/4168986/">Jirka Vejrazka</a>
(<a href="/recipes/tags/consumer/">consumer</a>, <a href="/recipes/tags/producer/">producer</a>, <a href="/recipes/tags/queue/">queue</a>, <a href="/recipes/tags/tag/">tag</a>).
Revision 2.
</p>
<p>I needed multiple consumers to retrieve data from a queue fed by one producer. Could not find a good working code for that, so I implemented my own queue. Docstring should describe how this works.</p>
<p>Two notes:
1) my code uses multiprocessing code, but in this module, the Lock and Condition could be easily replaced with the same objects from the threading module
2) the attached test uses syntax for "nose" testing package, I did not convert it to doctest or UnitTest.</p>
Get CPU Usage by using ctypes (Win32 Platform) (Python)
2009-01-26T06:43:38Z Shao-chuan Wang https://ActiveState%20Code/recipes/users/4168519/ https://code.activestate.com/recipes/576631/
<p style="color: grey">
Python
recipe 576631
by <a href="/recipes/users/4168519/">Shao-chuan Wang</a>
(<a href="/recipes/tags/CPU Usage/">CPU Usage</a>, <a href="/recipes/tags/ctypes/">ctypes</a>, <a href="/recipes/tags/System Programming/">System Programming</a>, <a href="/recipes/tags/Win32/">Win32</a>).
Revision 2.
</p>
<p>The following code has been tested at Windows XP sp2 with Python of version 2.5.4.</p>
Henderson and Tilton's formula (Python)
2009-01-26T00:13:59Z donyo Ganchev https://ActiveState%20Code/recipes/users/4167704/ https://code.activestate.com/recipes/576630/
<p style="color: grey">
Python
recipe 576630
by <a href="/recipes/users/4167704/">donyo Ganchev</a>
.
</p>
<p>Calculate a effectiveness of zoocides </p>
Calculator of pesticide concentration (Python)
2009-01-26T00:11:48Z donyo Ganchev https://ActiveState%20Code/recipes/users/4167704/ https://code.activestate.com/recipes/576629/
<p style="color: grey">
Python
recipe 576629
by <a href="/recipes/users/4167704/">donyo Ganchev</a>
.
</p>
<p>Calculate concentration of pesticides according to active substance</p>
Index of Mc. Kynney (Python)
2009-01-26T00:09:22Z donyo Ganchev https://ActiveState%20Code/recipes/users/4167704/ https://code.activestate.com/recipes/576628/
<p style="color: grey">
Python
recipe 576628
by <a href="/recipes/users/4167704/">donyo Ganchev</a>
.
</p>
<p>Calculation of the Index of Mc. Kynney (Index of Damage)</p>
BlueMon (Python)
2009-01-25T13:51:58Z Martin Reed https://ActiveState%20Code/recipes/users/4113342/ https://code.activestate.com/recipes/576627/
<p style="color: grey">
Python
recipe 576627
by <a href="/recipes/users/4113342/">Martin Reed</a>
(<a href="/recipes/tags/automate/">automate</a>, <a href="/recipes/tags/bluetooth/">bluetooth</a>, <a href="/recipes/tags/parallel port/">parallel port</a>, <a href="/recipes/tags/speech/">speech</a>, <a href="/recipes/tags/Ubuntu/">Ubuntu</a>).
</p>
<p>Scans for discoverable bluetooth devices every 35 seconds, and announces (with espeak in Ubuntu) and logs, devices which come into or out of range. Idea for automated processes like turning on exterior lighting and heating by the parallel port</p>
Skype chat to speech (Python)
2009-01-25T13:47:33Z Martin Reed https://ActiveState%20Code/recipes/users/4113342/ https://code.activestate.com/recipes/576626/
<p style="color: grey">
Python
recipe 576626
by <a href="/recipes/users/4113342/">Martin Reed</a>
(<a href="/recipes/tags/chat/">chat</a>, <a href="/recipes/tags/espeak/">espeak</a>, <a href="/recipes/tags/skype/">skype</a>, <a href="/recipes/tags/text to speech/">text to speech</a>, <a href="/recipes/tags/Ubuntu/">Ubuntu</a>).
</p>
<p>Using espeak text to speech in Ubuntu, and the skype4py module, this will read out the contents of chat messages recieved-created to help me when away from my PC so if i have my hands full with the younger members of my family I can decide how urgent the chat is without having to go near the computer.</p>
Poor man's mgrid (Python)
2009-01-21T15:37:13Z David Lambert https://ActiveState%20Code/recipes/users/4167420/ https://code.activestate.com/recipes/576625/
<p style="color: grey">
Python
recipe 576625
by <a href="/recipes/users/4167420/">David Lambert</a>
(<a href="/recipes/tags/index/">index</a>, <a href="/recipes/tags/index tricks/">index tricks</a>, <a href="/recipes/tags/method/">method</a>, <a href="/recipes/tags/mgrid/">mgrid</a>, <a href="/recipes/tags/numerical/">numerical</a>, <a href="/recipes/tags/numerical methods/">numerical methods</a>, <a href="/recipes/tags/numpy/">numpy</a>, <a href="/recipes/tags/python3/">python3</a>, <a href="/recipes/tags/scipy/">scipy</a>, <a href="/recipes/tags/trick/">trick</a>).
</p>
<p>Python 3 code.
scipy.mgrid is a useful!
This short implementation comes without installing numpy.</p>