Popular recipes tagged "meta:loc=91"http://code.activestate.com/recipes/tags/meta:loc=91/2015-12-18T20:59:43-08:00ActiveState Code Recipesbitfield rev2 (Python) 2014-08-17T16:40:55-07:00juanhttp://code.activestate.com/recipes/users/4190606/http://code.activestate.com/recipes/578922-bitfield-rev2/ <p style="color: grey"> Python recipe 578922 by <a href="/recipes/users/4190606/">juan</a> . </p> <p>python class bf for bitfields manipulation is a rev 2 for the <a href="http://code.activestate.com/recipes/113799/">Recipe 113799</a> rev 1 include the bug fix detected for Patric Edsall and other tools</p> Simple python thread manager (Python) 2012-12-17T16:19:12-08:00Tom Wissinghttp://code.activestate.com/recipes/users/4184629/http://code.activestate.com/recipes/578385-simple-python-thread-manager/ <p style="color: grey"> Python recipe 578385 by <a href="/recipes/users/4184629/">Tom Wissing</a> (<a href="/recipes/tags/manager/">manager</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/threading/">threading</a>, <a href="/recipes/tags/threads/">threads</a>). </p> <p>A simple python static class handling basic threading. Designed for "worker" threads that loop forever over a function and the like.</p> Simple python thread manager (Python) 2012-11-17T23:18:17-08:00Tino Deakhttp://code.activestate.com/recipes/users/4184300/http://code.activestate.com/recipes/578331-simple-python-thread-manager/ <p style="color: grey"> Python recipe 578331 by <a href="/recipes/users/4184300/">Tino Deak</a> (<a href="/recipes/tags/manager/">manager</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/threading/">threading</a>, <a href="/recipes/tags/threads/">threads</a>). </p> <p>A simple python static class handling basic threading. Designed for "worker" threads that loop forever over a function and the like.</p> threadbox.py (Python) 2012-10-09T22:40:09-07:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/578152-threadboxpy/ <p style="color: grey"> Python recipe 578152 by <a href="/recipes/users/2608421/">Stephen Chappell</a> (<a href="/recipes/tags/metaclass/">metaclass</a>, <a href="/recipes/tags/threading/">threading</a>). Revision 2. </p> <p>Provide a way to run instance methods on a single thread.</p> <p>This module allows hierarchical classes to be cloned so that their instances run on one thread. Method calls are automatically routed through a special execution engine. This is helpful when building thread-safe GUI code.</p> Console CD Player (Python) 2012-07-11T12:26:10-07:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/578207-console-cd-player/ <p style="color: grey"> Python recipe 578207 by <a href="/recipes/users/2608421/">Stephen Chappell</a> (<a href="/recipes/tags/archive/">archive</a>, <a href="/recipes/tags/console/">console</a>, <a href="/recipes/tags/old/">old</a>, <a href="/recipes/tags/playback/">playback</a>). </p> <p>You have probably seen many different GUI programs that can play music on CDs. Well, here is a console-based recipe that can do the same thing. This is committed for archival to be run under Python 2.5 or later versions.</p> Wait for PID and check for PID existance (POSIX) (Python) 2012-04-15T14:13:02-07:00Giampaolo Rodolàhttp://code.activestate.com/recipes/users/4178764/http://code.activestate.com/recipes/578022-wait-for-pid-and-check-for-pid-existance-posix/ <p style="color: grey"> Python recipe 578022 by <a href="/recipes/users/4178764/">Giampaolo Rodolà</a> (<a href="/recipes/tags/exists/">exists</a>, <a href="/recipes/tags/exit/">exit</a>, <a href="/recipes/tags/pid/">pid</a>, <a href="/recipes/tags/process/">process</a>, <a href="/recipes/tags/status/">status</a>, <a href="/recipes/tags/timeout/">timeout</a>, <a href="/recipes/tags/wait/">wait</a>). Revision 7. </p> <p>Two functions: one which waits for a certain PID to terminate (with optional timeout), another one which checks whether a process with a given PID is running.</p> <p>This was extracted from <a href="http://code.google.com/p/psutil/">psutil</a> project which also provides a Windows implementation.</p> <p>Timeout functionality is implemented as a busy loop and it was inspired by <a href="http://bugs.python.org/issue5673." rel="nofollow">http://bugs.python.org/issue5673.</a></p> extending xrange to support slicing and indexing (Python) 2012-03-13T16:13:16-07:00Garretthttp://code.activestate.com/recipes/users/4181290/http://code.activestate.com/recipes/578070-extending-xrange-to-support-slicing-and-indexing/ <p style="color: grey"> Python recipe 578070 by <a href="/recipes/users/4181290/">Garrett</a> (<a href="/recipes/tags/object/">object</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/xrange/">xrange</a>). </p> <p>an object which extends the xrange object to support slicing and indexing (simple)</p> Discrete PID Controller (Python) 2015-12-18T20:59:43-08:00Canerhttp://code.activestate.com/recipes/users/4114638/http://code.activestate.com/recipes/577231-discrete-pid-controller/ <p style="color: grey"> Python recipe 577231 by <a href="/recipes/users/4114638/">Caner</a> (<a href="/recipes/tags/controller/">controller</a>, <a href="/recipes/tags/derivative/">derivative</a>, <a href="/recipes/tags/discrete/">discrete</a>, <a href="/recipes/tags/integral/">integral</a>, <a href="/recipes/tags/pid/">pid</a>, <a href="/recipes/tags/proportional/">proportional</a>, <a href="/recipes/tags/python/">python</a>). </p> <p>The recipe gives simple implementation of a Discrete Proportional-Integral-Derivative (PID) controller. PID controller gives output value for error between desired reference input and measurement feedback to minimize error value. More information: <a href="http://en.wikipedia.org/wiki/PID_controller" rel="nofollow">http://en.wikipedia.org/wiki/PID_controller</a></p> <p><strong>For new version please check:</strong> <a href="https://github.com/ivmech/ivPID" rel="nofollow">https://github.com/ivmech/ivPID</a></p> Flatten XML to XPath syntax lines (Python) 2011-01-19T16:05:24-08:00Raphaël Jolivethttp://code.activestate.com/recipes/users/4135673/http://code.activestate.com/recipes/577547-flatten-xml-to-xpath-syntax-lines/ <p style="color: grey"> Python recipe 577547 by <a href="/recipes/users/4135673/">Raphaël Jolivet</a> (<a href="/recipes/tags/flatten/">flatten</a>, <a href="/recipes/tags/grep/">grep</a>, <a href="/recipes/tags/sed/">sed</a>, <a href="/recipes/tags/xml/">xml</a>, <a href="/recipes/tags/xpath/">xpath</a>). </p> <p>This script acts like <a href="http://www.ofb.net/~egnor/xml2/">xml2</a>. It transforms a XML file into a flat text output, with <em>XPath</em>-like syntax, one line per XML node or attribute. This format is more suitable for working with standard unix CLI utils (sed, grep, ... etc).</p> Simple numeric database (Python) 2011-05-16T08:41:46-07:00Mike Sweeneyhttp://code.activestate.com/recipes/users/4177990/http://code.activestate.com/recipes/577697-simple-numeric-database/ <p style="color: grey"> Python recipe 577697 by <a href="/recipes/users/4177990/">Mike Sweeney</a> (<a href="/recipes/tags/array/">array</a>, <a href="/recipes/tags/database/">database</a>, <a href="/recipes/tags/numeric/">numeric</a>). Revision 2. </p> <p>A simple in-memory numeric database for Python. Arrays are used to minimise memory consumption.</p> Simple numeric database (Python) 2011-05-16T12:11:24-07:00Hamidreza Joshaghanihttp://code.activestate.com/recipes/users/4177804/http://code.activestate.com/recipes/577698-simple-numeric-database/ <p style="color: grey"> Python recipe 577698 by <a href="/recipes/users/4177804/">Hamidreza Joshaghani</a> (<a href="/recipes/tags/array/">array</a>, <a href="/recipes/tags/database/">database</a>, <a href="/recipes/tags/numeric/">numeric</a>). </p> <p>A simple in-memory numeric database for Python. Arrays are used to minimise memory consumption.</p> Accented Characters for Tkinter Widgets (Python) 2011-01-07T13:09:51-08:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/576950-accented-characters-for-tkinter-widgets/ <p style="color: grey"> Python recipe 576950 by <a href="/recipes/users/2608421/">Stephen Chappell</a> (<a href="/recipes/tags/ui/">ui</a>). Revision 3. </p> <p>See <a href="http://code.activestate.com/recipes/286155/">Recipe 286155</a> for original code and author.</p> <p>This module provides two standard Tkinter widgets, Entry and ScrolledText, modified for text editing with key bindings that allow entering accented letters, umlauts, etc.</p> <p>Usage: To enter an accented character, press Ctrl-symbol, then press the character key. Example: to enter U with umlaut, press Ctrl-", U. For accent symbols that need shift, press Ctrl-Shift-symbol (for example, Ctrl-Shift-' if " is under Shift-').</p> <p>Accent bindings are defined in the Diacritical.accent table. Not all accents exist on all letters. This is handled by gracefully falling back to the base letter.</p> <p>Additional changes in default Tk key bindings: Ctrl-A is now select-all.</p> Authenticate with twisted.web.xmlrpc (Python) 2006-09-05T18:09:47-07:00Duncan McGreggorhttp://code.activestate.com/recipes/users/1923213/http://code.activestate.com/recipes/473865-authenticate-with-twistedwebxmlrpc/ <p style="color: grey"> Python recipe 473865 by <a href="/recipes/users/1923213/">Duncan McGreggor</a> (<a href="/recipes/tags/network/">network</a>). Revision 2. </p> <p>These classes subclass several of the culprits in twisted.web.xmlrpc that are responsible for not being able to make autenticated XML-RPC calls.</p> <p>Note that this recipe also makes use of the URI classes that were posted in a previous recipe here: <a href="http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/473864" rel="nofollow">http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/473864</a></p> <p>I will submit a patch to twisted along these lines, but there will be no references to the custom Uri module or code.</p> <p>Update: XML-RPC Authentication is now supported in Twisted (version 2.4 included a patch based on this recipe). If you are using a recent version of Twisted or can update to a recent version, this recipe is no longer needed.</p> How to use twisted pb pager (Python) 2005-11-28T03:04:25-08:00Matthew Sherbornehttp://code.activestate.com/recipes/users/2545860/http://code.activestate.com/recipes/457670-how-to-use-twisted-pb-pager/ <p style="color: grey"> Python recipe 457670 by <a href="/recipes/users/2545860/">Matthew Sherborne</a> (<a href="/recipes/tags/network/">network</a>). </p> <p>How to transfer large files with Twisted Perspective Broker using twisted.spread.util.Pager and friends. Code copied and pasted from here: <a href="http://twistedmatrix.com/pipermail/twisted-python/2003-May/004019.html" rel="nofollow">http://twistedmatrix.com/pipermail/twisted-python/2003-May/004019.html</a></p> <p>Just wanted to make it easier to find. Originally by: Glyph Lefkowitz</p> List all Type 1 Cyrillic fonts to one PDF file (Python) 2005-08-06T12:15:13-07:00Yuriy Tkachenkohttp://code.activestate.com/recipes/users/2011468/http://code.activestate.com/recipes/438818-list-all-type-1-cyrillic-fonts-to-one-pdf-file/ <p style="color: grey"> Python recipe 438818 by <a href="/recipes/users/2011468/">Yuriy Tkachenko</a> (<a href="/recipes/tags/text/">text</a>). </p> <p>This example uses ReportLab PDF library <a <a href="http://href=%22http://www.reportlab.com%22%3Ehttp://www.reportlab.com" rel="nofollow">href="http://www.reportlab.com">http://www.reportlab.com</a></a> and made from reportlab/demos/stdfonts/stdfonts.py demo. It generates tables showing all Type 1 fonts in Cyrillic cp1251 encoding in /usr/share/fonts/default/Type1 Linux directory. It may be helpful for choosing most suitable fonts for your documents.</p> Entering accented characters in Tkinter widgets (Python) 2005-01-12T22:00:07-08:00Artur de Sousa Rochahttp://code.activestate.com/recipes/users/343771/http://code.activestate.com/recipes/286155-entering-accented-characters-in-tkinter-widgets/ <p style="color: grey"> Python recipe 286155 by <a href="/recipes/users/343771/">Artur de Sousa Rocha</a> (<a href="/recipes/tags/ui/">ui</a>). Revision 4. </p> <p>This module provides two standard Tkinter widgets, Entry and ScrolledText, modified for text editing with key bindings that allow entering accented letters, umlauts, etc.</p> <p>Usage: To enter an accented character, press Ctrl-symbol, then press the character key. Example: to enter U with umlaut, press Ctrl-", U. For accent symbols that need shift, press Ctrl-Shift-symbol (for example, Ctrl-Shift-' if " is under Shift-').</p> <p>Accent bindings are defined in the Diacritical.accent table. Not all accents exist on all letters. This is handled by gracefully falling back to the base letter.</p> <p>Additional changes in default Tk key bindings: Ctrl-A is now select-all.</p> Console built with Cmd object (Python) 2004-04-27T12:50:16-07:00James Thielehttp://code.activestate.com/recipes/users/1779700/http://code.activestate.com/recipes/280500-console-built-with-cmd-object/ <p style="color: grey"> Python recipe 280500 by <a href="/recipes/users/1779700/">James Thiele</a> . </p> <p>This recipe shows how to use the Cmd object to create a simple OS neutral console. It shows how to use many of the hooks provided by the Cmd object and also documents some errors and omissions in the official cmd documentation,</p> import Outlook contacts using win32com (Python) 2003-01-10T19:59:18-08:00Kevin Altishttp://code.activestate.com/recipes/users/98071/http://code.activestate.com/recipes/173216-import-outlook-contacts-using-win32com/ <p style="color: grey"> Python recipe 173216 by <a href="/recipes/users/98071/">Kevin Altis</a> . Revision 3. </p> <p>This is a simple class and test code to read the Contacts from Outlook using win32com, which is part of Mark Hammond's win32all package.</p> Implementing C function callbacks using Python (Python) 2001-06-19T15:01:52-07:00pink chryhttp://code.activestate.com/recipes/users/99417/http://code.activestate.com/recipes/65210-implementing-c-function-callbacks-using-python/ <p style="color: grey"> Python recipe 65210 by <a href="/recipes/users/99417/">pink chry</a> (<a href="/recipes/tags/extending/">extending</a>). Revision 2. </p> <p>Lets say you have a function in C or C++ that takes a function callback as an argument. You want to call this function by passing a Python function as the callback. This recipe shows the basics by calling the standard C library function qsort, and passing a python function as the compare function.</p>