Popular recipes by Sébastien Keim http://code.activestate.com/recipes/users/131730/2003-08-05T00:46:30-07:00ActiveState Code RecipesHex dumper (Python) 2002-08-05T04:27:10-07:00Sébastien Keimhttp://code.activestate.com/recipes/users/131730/http://code.activestate.com/recipes/142812-hex-dumper/ <p style="color: grey"> Python recipe 142812 by <a href="/recipes/users/131730/">Sébastien Keim</a> (<a href="/recipes/tags/text/">text</a>). </p> <p>Hexadecimal display of a byte stream</p> Pretty sorting. (Python) 2003-08-05T00:46:30-07:00Sébastien Keimhttp://code.activestate.com/recipes/users/131730/http://code.activestate.com/recipes/214202-pretty-sorting/ <p style="color: grey"> Python recipe 214202 by <a href="/recipes/users/131730/">Sébastien Keim</a> (<a href="/recipes/tags/text/">text</a>). </p> <p>Sorting strings whith embeded numbers.</p> Assignment in expression (Python) 2003-05-26T14:15:40-07:00Sébastien Keimhttp://code.activestate.com/recipes/users/131730/http://code.activestate.com/recipes/202234-assignment-in-expression/ <p style="color: grey"> Python recipe 202234 by <a href="/recipes/users/131730/">Sébastien Keim</a> (<a href="/recipes/tags/shortcuts/">shortcuts</a>). Revision 2. </p> <p>An evil equivalent for C expression: 'while x=f()'.</p> Variant assertion (Python) 2003-05-20T00:32:09-07:00Sébastien Keimhttp://code.activestate.com/recipes/users/131730/http://code.activestate.com/recipes/200566-variant-assertion/ <p style="color: grey"> Python recipe 200566 by <a href="/recipes/users/131730/">Sébastien Keim</a> (<a href="/recipes/tags/debugging/">debugging</a>). </p> <p>Eiffel like loop variant assertion</p> Directory Iterator (Python) 2003-03-18T12:03:05-08:00Sébastien Keimhttp://code.activestate.com/recipes/users/131730/http://code.activestate.com/recipes/184602-directory-iterator/ <p style="color: grey"> Python recipe 184602 by <a href="/recipes/users/131730/">Sébastien Keim</a> (<a href="/recipes/tags/sysadmin/">sysadmin</a>). Revision 3. </p> <p>This iterator can bee used to walk through directories.</p> ASCII encoding guess (Python) 2002-11-22T03:37:38-08:00Sébastien Keimhttp://code.activestate.com/recipes/users/131730/http://code.activestate.com/recipes/163743-ascii-encoding-guess/ <p style="color: grey"> Python recipe 163743 by <a href="/recipes/users/131730/">Sébastien Keim</a> (<a href="/recipes/tags/text/">text</a>). </p> <p>This function can be used to check if a string contain only ASCII characters.</p> Fixed size cache (Python) 2002-11-26T03:13:07-08:00Sébastien Keimhttp://code.activestate.com/recipes/users/131730/http://code.activestate.com/recipes/164274-fixed-size-cache/ <p style="color: grey"> Python recipe 164274 by <a href="/recipes/users/131730/">Sébastien Keim</a> . </p> <p>When a function is expensive, it can be interesting to keep in cache the last computed values.</p> Slice equivalent for iterators. (Python) 2002-11-29T05:39:23-08:00Sébastien Keimhttp://code.activestate.com/recipes/users/131730/http://code.activestate.com/recipes/164740-slice-equivalent-for-iterators/ <p style="color: grey"> Python recipe 164740 by <a href="/recipes/users/131730/">Sébastien Keim</a> (<a href="/recipes/tags/search/">search</a>). </p> <p>This function allow to use a slice like protocol on iterators.</p> Deciphering Caesar code (Python) 2002-10-18T15:24:50-07:00Sébastien Keimhttp://code.activestate.com/recipes/users/131730/http://code.activestate.com/recipes/142813-deciphering-caesar-code/ <p style="color: grey"> Python recipe 142813 by <a href="/recipes/users/131730/">Sébastien Keim</a> (<a href="/recipes/tags/text/">text</a>). Revision 3. </p> <p>How to use letter frequencies analysis to decipher French and English texts.</p> Initializing attributes to a constant value (Python) 2002-10-14T04:07:17-07:00Sébastien Keimhttp://code.activestate.com/recipes/users/131730/http://code.activestate.com/recipes/156546-initializing-attributes-to-a-constant-value/ <p style="color: grey"> Python recipe 156546 by <a href="/recipes/users/131730/">Sébastien Keim</a> (<a href="/recipes/tags/shortcuts/">shortcuts</a>). </p> <p>You need to set some attributes to a constant value during object initialization.</p> bit field manipulation (Python) 2002-02-12T06:27:43-08:00Sébastien Keimhttp://code.activestate.com/recipes/users/131730/http://code.activestate.com/recipes/113799-bit-field-manipulation/ <p style="color: grey"> Python recipe 113799 by <a href="/recipes/users/131730/">Sébastien Keim</a> . </p> <p>List like protocol for bit field manipulation</p> Merging sorted sequences (Python) 2002-07-30T05:43:38-07:00Sébastien Keimhttp://code.activestate.com/recipes/users/131730/http://code.activestate.com/recipes/141934-merging-sorted-sequences/ <p style="color: grey"> Python recipe 141934 by <a href="/recipes/users/131730/">Sébastien Keim</a> (<a href="/recipes/tags/search/">search</a>). </p> <p>How to merge several iterable sequences and keep things ordered.</p> Forbidding inheritance (Python) 2002-07-30T05:24:04-07:00Sébastien Keimhttp://code.activestate.com/recipes/users/131730/http://code.activestate.com/recipes/141933-forbidding-inheritance/ <p style="color: grey"> Python recipe 141933 by <a href="/recipes/users/131730/">Sébastien Keim</a> (<a href="/recipes/tags/oop/">oop</a>). </p> <p>How to prevent the use of a class as a base class.</p> lazy attributes (Python) 2002-06-07T07:19:41-07:00Sébastien Keimhttp://code.activestate.com/recipes/users/131730/http://code.activestate.com/recipes/131495-lazy-attributes/ <p style="color: grey"> Python recipe 131495 by <a href="/recipes/users/131730/">Sébastien Keim</a> (<a href="/recipes/tags/oop/">oop</a>). Revision 3. </p> <p>How to create attributes with 'computed at first use' values.</p> spell checking (Python) 2002-03-12T12:59:07-08:00Sébastien Keimhttp://code.activestate.com/recipes/users/131730/http://code.activestate.com/recipes/117221-spell-checking/ <p style="color: grey"> Python recipe 117221 by <a href="/recipes/users/131730/">Sébastien Keim</a> (<a href="/recipes/tags/text/">text</a>). Revision 2. </p> <p>use popen2 module to drive the ispell typo checker</p> Ring buffer (Python) 2001-09-24T12:42:54-07:00Sébastien Keimhttp://code.activestate.com/recipes/users/131730/http://code.activestate.com/recipes/68429-ring-buffer/ <p style="color: grey"> Python recipe 68429 by <a href="/recipes/users/131730/">Sébastien Keim</a> (<a href="/recipes/tags/algorithms/">algorithms</a>). Revision 2. </p> <p>A ring buffer is a buffer with a fixed size. When it fills up, adding another element overwrites the first. It's particularly useful for the storage of log information. There is no direct support in Python for this kind of structure but it's easy to construct one.</p> <p>Here is a suggestion of implementation optimized for element insertion.</p> driving gnuplot with the popen function (Python) 2002-03-04T14:00:46-08:00Sébastien Keimhttp://code.activestate.com/recipes/users/131730/http://code.activestate.com/recipes/108287-driving-gnuplot-with-the-popen-function/ <p style="color: grey"> Python recipe 108287 by <a href="/recipes/users/131730/">Sébastien Keim</a> (<a href="/recipes/tags/sysadmin/">sysadmin</a>). Revision 2. </p> <p>os.popen is really great when you need to drive a text based software. Here is a sample of use which create animated graphics using the free software gnuplot.</p> Fifo as single linked lists (Python) 2002-01-18T09:10:37-08:00Sébastien Keimhttp://code.activestate.com/recipes/users/131730/http://code.activestate.com/recipes/68436-fifo-as-single-linked-lists/ <p style="color: grey"> Python recipe 68436 by <a href="/recipes/users/131730/">Sébastien Keim</a> (<a href="/recipes/tags/algorithms/">algorithms</a>). Revision 5. </p> <p>Fifo mean "First In First Out". This is a kind of container, which only allow element insertion and removal and where the first element inserted is the first element removed.</p> Reloading all modules (Python) 2001-10-15T02:08:03-07:00Sébastien Keimhttp://code.activestate.com/recipes/users/131730/http://code.activestate.com/recipes/81731-reloading-all-modules/ <p style="color: grey"> Python recipe 81731 by <a href="/recipes/users/131730/">Sébastien Keim</a> (<a href="/recipes/tags/debugging/">debugging</a>). </p> <p>When you create a Python module, you can use a test script wich import your module. But you probably have noticed that when you run the test script, it always use the first version of your module even if you made changes in the code. This is because the import statement check if the module is already in memory and do the import stuff only when this is mandated.</p> <p>You can use the reload() function but this is quite difficult if you do changes in a module wich isn't directly imported by your test script.</p> <p>A good solution could be to remove all modules from memory before running the test script. You only have to put some few lines at the start of your test script.</p> Using introspection to verify Eiffel like contracts (Python) 2001-10-15T06:59:40-07:00Sébastien Keimhttp://code.activestate.com/recipes/users/131730/http://code.activestate.com/recipes/81790-using-introspection-to-verify-eiffel-like-contract/ <p style="color: grey"> Python recipe 81790 by <a href="/recipes/users/131730/">Sébastien Keim</a> (<a href="/recipes/tags/programs/">programs</a>). </p> <p>This sample show how you can use intospection to create a function wraper that verify Eiffel like contracts.</p>