Popular recipes by Christopher Dunn http://code.activestate.com/recipes/users/1683375/2006-07-07T00:06:16-07:00ActiveState Code RecipesComputing permutations with duplicates (Python)
2006-07-07T00:06:16-07:00Christopher Dunnhttp://code.activestate.com/recipes/users/1683375/http://code.activestate.com/recipes/496869-computing-permutations-with-duplicates/
<p style="color: grey">
Python
recipe 496869
by <a href="/recipes/users/1683375/">Christopher Dunn</a>
(<a href="/recipes/tags/algorithms/">algorithms</a>).
Revision 3.
</p>
<p>This handles duplicate values in the list. It could easily be made a generator, and it does not require recursion.</p>
Read/write object for pkg-config files (Python)
2006-06-29T23:33:27-07:00Christopher Dunnhttp://code.activestate.com/recipes/users/1683375/http://code.activestate.com/recipes/496852-readwrite-object-for-pkg-config-files/
<p style="color: grey">
Python
recipe 496852
by <a href="/recipes/users/1683375/">Christopher Dunn</a>
(<a href="/recipes/tags/sysadmin/">sysadmin</a>).
Revision 2.
</p>
<p>Here is a convenient way to create, parse, alter, and write .pc files. Just pass PkgConfig() a file-like object, or None to start fresh. Print the object to create a new .pc file.</p>
<p>Some people might want even more functionality, but I chose not to hinder the flexibility of the class.</p>
Stack-based indentation of formatted logging (Python)
2005-04-28T23:27:16-07:00Christopher Dunnhttp://code.activestate.com/recipes/users/1683375/http://code.activestate.com/recipes/412603-stack-based-indentation-of-formatted-logging/
<p style="color: grey">
Python
recipe 412603
by <a href="/recipes/users/1683375/">Christopher Dunn</a>
(<a href="/recipes/tags/debugging/">debugging</a>).
Revision 3.
</p>
<p>Some people like to sprinkle stack trace information in their code, and it is always helpful to get a visual clue to the call stack depth. inspect.stack() contains the entire call stack.</p>
<p>To make this information available conditionally, on a per-subsystem basis, the logging module is helpful. Here is one way to combine the two ideas.</p>
Using the logging module (Python)
2005-05-04T05:41:45-07:00Christopher Dunnhttp://code.activestate.com/recipes/users/1683375/http://code.activestate.com/recipes/412552-using-the-logging-module/
<p style="color: grey">
Python
recipe 412552
by <a href="/recipes/users/1683375/">Christopher Dunn</a>
(<a href="/recipes/tags/debugging/">debugging</a>).
Revision 7.
</p>
<p>This amazingly powerful module is a mystery to novices. Once you figure it out, you'll use it everywhere.</p>
<p>In addition to examples, here are a couple of useful filters.</p>
Numbers and plural words as spoken English (Python)
2005-05-18T11:07:20-07:00Christopher Dunnhttp://code.activestate.com/recipes/users/1683375/http://code.activestate.com/recipes/413172-numbers-and-plural-words-as-spoken-english/
<p style="color: grey">
Python
recipe 413172
by <a href="/recipes/users/1683375/">Christopher Dunn</a>
(<a href="/recipes/tags/text/">text</a>).
Revision 3.
</p>
<p>Have you seen error reports that say
"1 errors detected"
or
"2 error found"
and thought there must be a better way?</p>
<p>There is!</p>