Popular Python recipes tagged "meta:requires=textwrap"http://code.activestate.com/recipes/langs/python/tags/meta:requires=textwrap/2012-05-18T14:34:13-07:00ActiveState Code Recipesgprof2dot.py (Python)
2012-05-18T14:34:13-07:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/578138-gprof2dotpy/
<p style="color: grey">
Python
recipe 578138
by <a href="/recipes/users/2608421/">Stephen Chappell</a>
(<a href="/recipes/tags/profiling/">profiling</a>, <a href="/recipes/tags/tools/">tools</a>, <a href="/recipes/tags/visualization/">visualization</a>).
</p>
<p>This is the <code>gprof2dot.py</code> program converted for use with the latest version of Python (3.2). It generates a dot graph from the output of several profilers. Please observe the original License embedded by the author, Jose Fonseca. His website for this program can be found on <a href="http://code.google.com/p/jrfonseca/wiki/Gprof2Dot">Google Code</a>.</p>
Quiz Me 2.5 (gui_logs) (Python)
2011-01-10T03:43:42-08:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/577527-quiz-me-25-gui_logs/
<p style="color: grey">
Python
recipe 577527
by <a href="/recipes/users/2608421/">Stephen Chappell</a>
(<a href="/recipes/tags/gui/">gui</a>, <a href="/recipes/tags/program/">program</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/quiz/">quiz</a>).
</p>
<p>Before discovering <a href="http://quizlet.com/" rel="nofollow">http://quizlet.com/</a>, the following program was developed for running custom quizzes to help with studying for college courses. The program is not very advanced, but it works reasonably well for what it was designed to do. If the program were developed further, it would need greater capabilities than it currently has and would require a secondary system for actually creating the quizzes (currently, they are hand-typed). Quiz Me could be a starting point for anyone who wishes to actually write a program such as this and inspire others to write much better programs than what this recipe currently offers.</p>
<p>There are several dialogs used throughout Quiz Me, and this module implements most of them. The standard dialog class in "tkinter.simpledialog" is modified slightly and used as a base class for the rest of the dialogs. ShowStatus displays whether a tier of the quiz is being entered or exited. AskQuestion allows questions to be asked and answered. ReviewProblems can be used to cycle through questions that were answered incorrectly. ShowReport gives a readout of the current cumulative progress score earned in the quiz. </p>
ReadOnlyPrivateSingletonImplicitThisMetaClass (Python)
2010-05-10T08:34:32-07:00Chris Joneshttp://code.activestate.com/recipes/users/4171447/http://code.activestate.com/recipes/577221-readonlyprivatesingletonimplicitthismetaclass/
<p style="color: grey">
Python
recipe 577221
by <a href="/recipes/users/4171447/">Chris Jones</a>
(<a href="/recipes/tags/enterprise/">enterprise</a>, <a href="/recipes/tags/implicit/">implicit</a>, <a href="/recipes/tags/private/">private</a>, <a href="/recipes/tags/readonly/">readonly</a>, <a href="/recipes/tags/self/">self</a>, <a href="/recipes/tags/singleton/">singleton</a>).
Revision 3.
</p>
<p>Are you a totally agile rock star developer? Turn your code into a rock concert with this handy metaclass that makes your classes suitable for production deployment!</p>
Align text filter (Python)
2010-03-09T07:34:43-08:00Denis Barmenkovhttp://code.activestate.com/recipes/users/57155/http://code.activestate.com/recipes/577093-align-text-filter/
<p style="color: grey">
Python
recipe 577093
by <a href="/recipes/users/57155/">Denis Barmenkov</a>
(<a href="/recipes/tags/align/">align</a>, <a href="/recipes/tags/pipe/">pipe</a>, <a href="/recipes/tags/text/">text</a>, <a href="/recipes/tags/wrap/">wrap</a>).
Revision 4.
</p>
<p>Python 2.3 module textwrap can justify text in three modes: left/right/center.
Sometimes 'align' mode become more useful.</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>
Dump all Active Directory Information using LDAP scripting (Python)
2007-04-04T17:07:38-07:00Manuel Garciahttp://code.activestate.com/recipes/users/2827266/http://code.activestate.com/recipes/511451-dump-all-active-directory-information-using-ldap-s/
<p style="color: grey">
Python
recipe 511451
by <a href="/recipes/users/2827266/">Manuel Garcia</a>
(<a href="/recipes/tags/network/">network</a>).
</p>
<p>From Active Directory (or any other LDAP server) dump ALL information about computers, users, and groups, in a nicely formatted report.</p>
Robust Textual Tables (Python)
2007-05-06T06:25:08-07:00Richard Harrishttp://code.activestate.com/recipes/users/4050195/http://code.activestate.com/recipes/519618-robust-textual-tables/
<p style="color: grey">
Python
recipe 519618
by <a href="/recipes/users/4050195/">Richard Harris</a>
(<a href="/recipes/tags/text/">text</a>).
Revision 3.
</p>
<p>This function will display a nicely formatted textual table for you. Features include: auto-sizing of columns, auto-alignment based on column-type (which it sniffs from the first row), nicely formated centered headings, and most importantly wrapping of cells. Of course, you can manually override pretty much everything in case you don't like the defaults.</p>
ElementTree Text Helper (Python)
2006-11-29T22:20:13-08:00Raymond Hettingerhttp://code.activestate.com/recipes/users/178123/http://code.activestate.com/recipes/498286-elementtree-text-helper/
<p style="color: grey">
Python
recipe 498286
by <a href="/recipes/users/178123/">Raymond Hettinger</a>
(<a href="/recipes/tags/xml/">xml</a>).
Revision 4.
</p>
<p>Solves the "tail-problem" for prose-oriented XML. Recursively pulls text out of elements and their sub-elements. Extracts text from DocBook, XMHTL, and other nested XML markup.</p>
Chomsky random text generator (Python)
2005-09-13T18:46:01-07:00Raymond Hettingerhttp://code.activestate.com/recipes/users/178123/http://code.activestate.com/recipes/440546-chomsky-random-text-generator/
<p style="color: grey">
Python
recipe 440546
by <a href="/recipes/users/178123/">Raymond Hettinger</a>
(<a href="/recipes/tags/text/">text</a>).
Revision 2.
</p>
<p>Creates believable Chomsky style obfuscated prose.</p>
Hierarchical Split (Python)
2006-02-19T13:23:14-08:00bearophile -http://code.activestate.com/recipes/users/2403049/http://code.activestate.com/recipes/440663-hierarchical-split/
<p style="color: grey">
Python
recipe 440663
by <a href="/recipes/users/2403049/">bearophile -</a>
(<a href="/recipes/tags/text/">text</a>).
Revision 4.
</p>
<p>To split a string more times, hierarchically.</p>
Align text string using spaces between words to fit specified width (Python)
2010-03-09T07:04:19-08:00Denis Barmenkovhttp://code.activestate.com/recipes/users/57155/http://code.activestate.com/recipes/414870-align-text-string-using-spaces-between-words-to-fi/
<p style="color: grey">
Python
recipe 414870
by <a href="/recipes/users/57155/">Denis Barmenkov</a>
(<a href="/recipes/tags/text/">text</a>).
Revision 5.
</p>
<p>Python 2.3 module textwrap can justify text in three modes: left/right/center.
Sometimes 'align' mode become more useful.</p>
A simple and useful doctester for your documentation (Python)
2005-04-16T09:15:09-07:00Michele Simionatohttp://code.activestate.com/recipes/users/1122360/http://code.activestate.com/recipes/410052-a-simple-and-useful-doctester-for-your-documentati/
<p style="color: grey">
Python
recipe 410052
by <a href="/recipes/users/1122360/">Michele Simionato</a>
(<a href="/recipes/tags/programs/">programs</a>).
Revision 3.
</p>
<p>The doctester extracts code from stdin and tests it using the doctest module in
the standard library. It can be invoked from the command line, but it is
best called from you editor of choice. I just give an example for Emacs.</p>
extend textwrap.TextWrapper to handle multiple paragraphs (Python)
2004-12-11T02:04:02-08:00Brett Cannonhttp://code.activestate.com/recipes/users/98030/http://code.activestate.com/recipes/358228-extend-textwraptextwrapper-to-handle-multiple-para/
<p style="color: grey">
Python
recipe 358228
by <a href="/recipes/users/98030/">Brett Cannon</a>
(<a href="/recipes/tags/text/">text</a>).
</p>
<p>textwrap is a very handy module. The problem with it, though, is that it expects to be used with individual paragraphs. But what if you want to wrap an entire document? It will still wrap the lines, but it will improperly consider it all a single paragraph.</p>
<p>This recipe alleviates that issue by overriding textwrap.TextWrapper.wrap with an implementation that handles spiltting a document into paragraphs and processing each individually. This allows things such as initial_indent to work as expected.</p>
linenum.py (Python)
2004-04-19T18:33:09-07:00Edward Joneshttp://code.activestate.com/recipes/users/1766124/http://code.activestate.com/recipes/279155-linenumpy/
<p style="color: grey">
Python
recipe 279155
by <a href="/recipes/users/1766124/">Edward Jones</a>
(<a href="/recipes/tags/debugging/">debugging</a>).
</p>
<p>Prints the current line number, function name and some text. Useful for debugging.</p>