Popular Python recipes tagged "meta:requires=atexit"http://code.activestate.com/recipes/langs/python/tags/meta:requires=atexit/2009-11-18T21:37:55-08:00ActiveState Code Recipeshow to implement kbhit() on Linux (Python)
2008-05-03T05:13:00-07:00Nelson Rushhttp://code.activestate.com/recipes/users/144881/http://code.activestate.com/recipes/572182-how-to-implement-kbhit-on-linux/
<p style="color: grey">
Python
recipe 572182
by <a href="/recipes/users/144881/">Nelson Rush</a>
.
Revision 2.
</p>
<p>kbhit on linux, the sample just prints dots until you press any key. I updated the sample to show how to implement unbuffered getch and getche safely.</p>
Low-impact script timing (Python)
2008-07-30T08:43:03-07:00Paul McGuirehttp://code.activestate.com/recipes/users/1377254/http://code.activestate.com/recipes/573436-low-impact-script-timing/
<p style="color: grey">
Python
recipe 573436
by <a href="/recipes/users/1377254/">Paul McGuire</a>
(<a href="/recipes/tags/debugging/">debugging</a>).
Revision 3.
</p>
<p>As other timing recipes have mentioned, the timeit module could be easier to work with. Sometimes, I just want to bracket a particular script with start, stop, and duration timing info. The following module (which I named "timing.py") is about as non-intrusive as you can get - just import the module.</p>
Cleaning up when killed (Python)
2007-09-27T10:33:56-07:00Miki Tebekahttp://code.activestate.com/recipes/users/4086267/http://code.activestate.com/recipes/533117-cleaning-up-when-killed/
<p style="color: grey">
Python
recipe 533117
by <a href="/recipes/users/4086267/">Miki Tebeka</a>
(<a href="/recipes/tags/sysadmin/">sysadmin</a>).
</p>
<p>atexit handlers are not called when a process is killed, this recipe show how to fix that.</p>
Semi-automatic resource management with AutoClose (Python)
2009-11-18T21:37:55-08:00Michele Simionatohttp://code.activestate.com/recipes/users/1122360/http://code.activestate.com/recipes/523007-semi-automatic-resource-management-with-autoclose/
<p style="color: grey">
Python
recipe 523007
by <a href="/recipes/users/1122360/">Michele Simionato</a>
(<a href="/recipes/tags/oop/">oop</a>).
Revision 4.
</p>
<p>This recipe provides a semi-automatic mechanism to close resources.</p>
Completer with history viewer support and more features (Python)
2006-06-29T01:22:23-07:00Sunjoong LEEhttp://code.activestate.com/recipes/users/2925478/http://code.activestate.com/recipes/496822-completer-with-history-viewer-support-and-more-fea/
<p style="color: grey">
Python
recipe 496822
by <a href="/recipes/users/2925478/">Sunjoong LEE</a>
.
Revision 10.
</p>
<p>This module let "tab" key can indent and completing valid python identifiers, keywords, and filenames.
This module support history view also.</p>
<p>Note1: original python rlcompleter module only avail in unix-like environment
Note2: if you seek a more simple completer you could try Jian Ding Chen's recipe at: <a href="http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496812" rel="nofollow">http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496812</a></p>
History and completion for the python shell (Python)
2006-02-17T18:43:19-08:00Vinko Vrsalovichttp://code.activestate.com/recipes/users/2781993/http://code.activestate.com/recipes/473900-history-and-completion-for-the-python-shell/
<p style="color: grey">
Python
recipe 473900
by <a href="/recipes/users/2781993/">Vinko Vrsalovic</a>
.
</p>
<p>This script creates a history file to share between your interactive python sessions, controlling its size in either lines or bytes. You have to put it in your PYTHONSTARTUP environment variable. As it uses readline, it only works under Unix systems. It also binds the tab key to complete words in the shell</p>
a better better command line calculator (Python)
2006-01-27T07:49:02-08:00Eli Criffieldhttp://code.activestate.com/recipes/users/2754246/http://code.activestate.com/recipes/473796-a-better-better-command-line-calculator/
<p style="color: grey">
Python
recipe 473796
by <a href="/recipes/users/2754246/">Eli Criffield</a>
.
</p>
<p>Eli Criffield <a href="mailto:python@zendo.net">python@zendo.net</a>
avalible at <a href="http://eli.criffield.net/sum/" rel="nofollow">http://eli.criffield.net/sum/</a>
a better better command line calculator,</p>
<p>put this in a file, run it, cut and past a bunch of numbers (don't
worry about the $ signs and commas) hit enter and it adds them up
use / * - + like normal</p>
<p>added features over just using python as a command line calculator:</p>
<ul>
<li>numbers can include ,s and $s or anything really and it still works
this allows you to cut and paste things like $1,123.65 and it still works</li>
<li>add by default! (unless you run with -x)
cut and paste a bunch of numbers hit enter and it'll add them all up</li>
<li>command line history and readline, up arrow recalls your history
even between sessions</li>
<li>_ is the last answer, just like in python</li>
</ul>