Popular recipes tagged "meta:requires=keyword"http://code.activestate.com/recipes/tags/meta:requires=keyword/2014-08-02T02:56:12-07:00ActiveState Code RecipesYet Another NamedTuple (Python)
2014-08-02T02:56:12-07:00Steven D'Apranohttp://code.activestate.com/recipes/users/4172944/http://code.activestate.com/recipes/578918-yet-another-namedtuple/
<p style="color: grey">
Python
recipe 578918
by <a href="/recipes/users/4172944/">Steven D'Aprano</a>
(<a href="/recipes/tags/shortcuts/">shortcuts</a>).
</p>
<p>Yet another look at Raymond Hettinger's excellent "namedtuple" factory. Unlike Raymond's version, this one minimizes the use of exec. In the original, the entire inner class is dynamically generated then exec'ed, leading to the bulk of the code being inside a giant string template. This version uses a regular inner class for everything except the __new__ method.</p>
Named Sequences for environments containing large numbers of POD instances (Python)
2010-11-27T13:55:18-08:00Kevin L. Sitzehttp://code.activestate.com/recipes/users/4173535/http://code.activestate.com/recipes/577473-named-sequences-for-environments-containing-large-/
<p style="color: grey">
Python
recipe 577473
by <a href="/recipes/users/4173535/">Kevin L. Sitze</a>
(<a href="/recipes/tags/decorator/">decorator</a>, <a href="/recipes/tags/memory/">memory</a>, <a href="/recipes/tags/sequence/">sequence</a>, <a href="/recipes/tags/slot/">slot</a>, <a href="/recipes/tags/unittests/">unittests</a>).
</p>
<p>Generate classes with named data attributes that can be sequenced.
Useful for POD classes for which many records will exist concurrently.</p>
<p>Compare the feature set to NamedTuples by Raymond Hettinger:
<a href="http://code.activestate.com/recipes/500261-named-tuples/" rel="nofollow">http://code.activestate.com/recipes/500261-named-tuples/</a></p>
Named Tuples (Python)
2009-05-26T22:44:39-07:00Raymond Hettingerhttp://code.activestate.com/recipes/users/178123/http://code.activestate.com/recipes/500261-named-tuples/
<p style="color: grey">
Python
recipe 500261
by <a href="/recipes/users/178123/">Raymond Hettinger</a>
(<a href="/recipes/tags/shortcuts/">shortcuts</a>).
Revision 15.
</p>
<p>Fast, lightweight attribute-style access to tuples.</p>
Records (Python)
2008-11-04T06:52:42-08:00George Sakkishttp://code.activestate.com/recipes/users/2591466/http://code.activestate.com/recipes/576555-records/
<p style="color: grey">
Python
recipe 576555
by <a href="/recipes/users/2591466/">George Sakkis</a>
(<a href="/recipes/tags/datastructures/">datastructures</a>, <a href="/recipes/tags/namedtuple/">namedtuple</a>, <a href="/recipes/tags/record/">record</a>).
</p>
<p>This is a recipe similar in functionality and exec-style optimized implementation to the very well received namedtuple (<a href="http://code.activestate.com/recipes/500261/" rel="nofollow">http://code.activestate.com/recipes/500261/</a>) that was included in Python 2.6. The main difference is that <strong>records</strong>, unlike named tuples, are mutable. In addition, fields can have a default value. Instead of subclassing tuple or list, the implementation create a regular class with __slots__.</p>
Python Syntax Highlighting in OpenOffice Impress (Python)
2009-06-04T12:24:04-07:00Bryan Colehttp://code.activestate.com/recipes/users/4170610/http://code.activestate.com/recipes/576796-python-syntax-highlighting-in-openoffice-impress/
<p style="color: grey">
Python
recipe 576796
by <a href="/recipes/users/4170610/">Bryan Cole</a>
(<a href="/recipes/tags/highlighting/">highlighting</a>, <a href="/recipes/tags/impress/">impress</a>, <a href="/recipes/tags/openoffice/">openoffice</a>, <a href="/recipes/tags/syntax/">syntax</a>).
</p>
<p>Applies python syntax highlighting to all the TextShapes (i.e. text boxes) in an OpenOffice document with the "code" graphic style applied. Typical usage is for highlighting code snippets in an Impress presentation. I have the "HighlightPython" function assigned to a menu item in my Tools menu for easy access. </p>
Python source to XHTML colorizer (Python)
2005-10-26T00:36:06-07:00Peter Krantzhttp://code.activestate.com/recipes/users/2641582/http://code.activestate.com/recipes/442482-python-source-to-xhtml-colorizer/
<p style="color: grey">
Python
recipe 442482
by <a href="/recipes/users/2641582/">Peter Krantz</a>
.
</p>
<p>Converts Python source to a portable XHTML 1.0 strict document that includes a basic set of Dublin Core metadata. Based on the MoinMoin source colorizer.</p>
Generate Python Symbol Lists for a Programmer's Editor Syntax Coloring File (Python)
2003-05-20T13:07:58-07:00Jim Jinkinshttp://code.activestate.com/recipes/users/1170097/http://code.activestate.com/recipes/200638-generate-python-symbol-lists-for-a-programmers-edi/
<p style="color: grey">
Python
recipe 200638
by <a href="/recipes/users/1170097/">Jim Jinkins</a>
(<a href="/recipes/tags/sysadmin/">sysadmin</a>).
</p>
<p>Use reflection to generate lists of Python symbols. Use them to build a syntax coloring file for your preferred programmer's editor.</p>
<p>This is easier and less error-prone than updating your syntax file by reading "What's New In Version x" and other documentation.</p>
Colorize Python source using the built-in tokenizer (Python)
2001-04-06T23:05:53-07:00Jürgen Hermannhttp://code.activestate.com/recipes/users/98061/http://code.activestate.com/recipes/52298-colorize-python-source-using-the-built-in-tokenize/
<p style="color: grey">
Python
recipe 52298
by <a href="/recipes/users/98061/">Jürgen Hermann</a>
(<a href="/recipes/tags/programs/">programs</a>).
Revision 3.
</p>
<p>This code is part of MoinMoin (<a href="http://moin.sourceforge.net/" rel="nofollow">http://moin.sourceforge.net/</a>) and converts Python source code to HTML markup, rendering comments, keywords, operators, numeric and string literals in different colors.</p>
<p>It shows how to use the built-in keyword, token and tokenize modules to scan Python source code and re-emit it with no changes to its original formatting (which is the hard part).</p>
<p>The test code at the bottom of the module formats itself and launches a browser with the result.</p>
Building GTK GUIs interactively (Python)
2001-09-27T15:49:21-07:00Brian McErleanhttp://code.activestate.com/recipes/users/111980/http://code.activestate.com/recipes/65109-building-gtk-guis-interactively/
<p style="color: grey">
Python
recipe 65109
by <a href="/recipes/users/111980/">Brian McErlean</a>
(<a href="/recipes/tags/ui/">ui</a>).
Revision 3.
</p>
<p>One of pythons greatest strengths is the ability to try things interactively at the interpreter.
Using Tkinter shares this strength, since one can create buttons, windows and other widgets,
and instantly see them onscreen, click on buttons to activate callbacks and still be able to
edit and add to the widgets from the python command line.</p>
<p>While the python GTK bindings are generally excellent, one of their flaws is that this is not possible.
Before anything is actually displayed, the gtk.mainloop() function must be called, ending the
possibility of interactive manipulation.</p>
<p>This recipe is a program which simulates a python interpreter which transparently allows the user to
use gtk widgets without having to call mainloop(), in much the same way as Tk widgets.</p>
<p>This latest version contains enhancements added by Christian Robottom Reis to add readline completion support.</p>