Popular recipes by Dirk Holtwick http://code.activestate.com/recipes/users/636691/2013-07-11T06:15:27-07:00ActiveState Code RecipesHTML/CSS to PDF converter (Python) 2008-04-20T06:06:52-07:00Dirk Holtwickhttp://code.activestate.com/recipes/users/636691/http://code.activestate.com/recipes/572160-htmlcss-to-pdf-converter/ <p style="color: grey"> Python recipe 572160 by <a href="/recipes/users/636691/">Dirk Holtwick</a> (<a href="/recipes/tags/web/">web</a>). </p> <p>Most people know how to write a page with HTML and CSS. Why not using these skills to dynamically generate PDF documents using it? The open source project "pisa" <a href="http://www.htmltopdf.org" rel="nofollow">http://www.htmltopdf.org</a> enables you to to this quite simple in a pythonic way.</p> Pure Python PDF to text converter (Python) 2007-04-12T11:05:10-07:00Dirk Holtwickhttp://code.activestate.com/recipes/users/636691/http://code.activestate.com/recipes/511465-pure-python-pdf-to-text-converter/ <p style="color: grey"> Python recipe 511465 by <a href="/recipes/users/636691/">Dirk Holtwick</a> (<a href="/recipes/tags/text/">text</a>). Revision 2. </p> <p>This example shows how to extract text informations from a PDF file without the need of system dependent tools or code. Just use the pyPdf library from <a href="http://pybrary.net/pyPdf/" rel="nofollow">http://pybrary.net/pyPdf/</a></p> Unsupported sitecustomize.py sinze Python 2.5 (Python) 2008-03-26T12:23:19-07:00Dirk Holtwickhttp://code.activestate.com/recipes/users/636691/http://code.activestate.com/recipes/552729-unsupported-sitecustomizepy-sinze-python-25/ <p style="color: grey"> Python recipe 552729 by <a href="/recipes/users/636691/">Dirk Holtwick</a> (<a href="/recipes/tags/sysadmin/">sysadmin</a>). </p> <p>Since Python 2.5 the automatic import of the module "sitecustomize.py" in the directory of the main program is not supported any more (even if the documentation says that it is). Putting this little script named "sitecustomize.py" in the default Python path like in "site-packages" should solve this problem.</p> Import of subpackages from different physical locations (Python) 2008-01-10T06:03:03-08:00Dirk Holtwickhttp://code.activestate.com/recipes/users/636691/http://code.activestate.com/recipes/542192-import-of-subpackages-from-different-physical-loca/ <p style="color: grey"> Python recipe 542192 by <a href="/recipes/users/636691/">Dirk Holtwick</a> (<a href="/recipes/tags/programs/">programs</a>). </p> <p>If you want do distribute different modules in separate packages but under the same top directory that may be a problem when importing those modules. Since Python 2.5 the "pkgutil", described in the Python documentation under chapter 29.3, solves this problem.</p> Count PDF pages (Python) 2013-07-11T06:15:27-07:00Dirk Holtwickhttp://code.activestate.com/recipes/users/636691/http://code.activestate.com/recipes/496837-count-pdf-pages/ <p style="color: grey"> Python recipe 496837 by <a href="/recipes/users/636691/">Dirk Holtwick</a> (<a href="/recipes/tags/files/">files</a>). </p> <p>A simple way to count the pages of a PDF the pure Python way.</p> Some missing string functions (Python) 2006-05-30T02:00:31-07:00Dirk Holtwickhttp://code.activestate.com/recipes/users/636691/http://code.activestate.com/recipes/496752-some-missing-string-functions/ <p style="color: grey"> Python recipe 496752 by <a href="/recipes/users/636691/">Dirk Holtwick</a> (<a href="/recipes/tags/text/">text</a>). </p> <p>While processing text I felt some functions are missing, espacially for international texts. Here are some helpers.</p> Hidden Scanner functionality in re module (Python) 2005-12-02T07:33:16-08:00Dirk Holtwickhttp://code.activestate.com/recipes/users/636691/http://code.activestate.com/recipes/457664-hidden-scanner-functionality-in-re-module/ <p style="color: grey"> Python recipe 457664 by <a href="/recipes/users/636691/">Dirk Holtwick</a> (<a href="/recipes/tags/text/">text</a>). Revision 2. </p> <p>The developers of Python hide a very nice function in the re module for scanning text. The example is taken from the Python testsuite: <a href="http://mail.python.org/pipermail/python-dev/2003-April/035075.html" rel="nofollow">http://mail.python.org/pipermail/python-dev/2003-April/035075.html</a></p> Debug runtime objects using gc.get_objects() (Python) 2005-11-27T08:01:49-08:00Dirk Holtwickhttp://code.activestate.com/recipes/users/636691/http://code.activestate.com/recipes/457665-debug-runtime-objects-using-gcget_objects/ <p style="color: grey"> Python recipe 457665 by <a href="/recipes/users/636691/">Dirk Holtwick</a> (<a href="/recipes/tags/debugging/">debugging</a>). </p> <p>Since Python 2.2 there is a handy function in the Garbage Collection Module called get_objects(). It gives back a list of all objects that are under control of the Garbeage Collector. This way you can extract informations of your application in runtime.</p> Reduce memory usage of "re" module (Python) 2005-11-27T07:22:14-08:00Dirk Holtwickhttp://code.activestate.com/recipes/users/636691/http://code.activestate.com/recipes/457662-reduce-memory-usage-of-re-module/ <p style="color: grey"> Python recipe 457662 by <a href="/recipes/users/636691/">Dirk Holtwick</a> (<a href="/recipes/tags/debugging/">debugging</a>). </p> <p>My company wrote an application server that works as a long running service. We were confronted with a memory usage that we couldn't explain until we found out, that the re module is caching a lot of data in the background.</p> Debuging of object instantiation (Python) 2005-11-27T09:05:11-08:00Dirk Holtwickhttp://code.activestate.com/recipes/users/636691/http://code.activestate.com/recipes/457666-debuging-of-object-instantiation/ <p style="color: grey"> Python recipe 457666 by <a href="/recipes/users/636691/">Dirk Holtwick</a> (<a href="/recipes/tags/debugging/">debugging</a>). </p> <p>If you are debugging a program you may want to know if some special objects exist and where they came from.</p> SuperGlobal, access global values from every module (Python) 2005-11-27T10:51:09-08:00Dirk Holtwickhttp://code.activestate.com/recipes/users/636691/http://code.activestate.com/recipes/457667-superglobal-access-global-values-from-every-module/ <p style="color: grey"> Python recipe 457667 by <a href="/recipes/users/636691/">Dirk Holtwick</a> (<a href="/recipes/tags/sysadmin/">sysadmin</a>). </p> <p>Sometimes you like to have a very global namespace where to put e.g. configuration data. This data should be accessible form all modules you use. SuperGlobal solves this need.</p> Simple stoppable server using socket timeout (Python) 2005-06-09T00:35:47-07:00Dirk Holtwickhttp://code.activestate.com/recipes/users/636691/http://code.activestate.com/recipes/425210-simple-stoppable-server-using-socket-timeout/ <p style="color: grey"> Python recipe 425210 by <a href="/recipes/users/636691/">Dirk Holtwick</a> (<a href="/recipes/tags/network/">network</a>). </p> <p>The usual Python HTTP server never stops. Since there is the timout option in the socket module, there is an easy way to do a clean shutdown of a running server.</p> Guess language of text using ZIP (Python) 2004-12-07T10:33:50-08:00Dirk Holtwickhttp://code.activestate.com/recipes/users/636691/http://code.activestate.com/recipes/355807-guess-language-of-text-using-zip/ <p style="color: grey"> Python recipe 355807 by <a href="/recipes/users/636691/">Dirk Holtwick</a> (<a href="/recipes/tags/algorithms/">algorithms</a>). Revision 3. </p> <p>A small tool for language and author identification of textfiles. More ore less a proof-of-concept of an article that I found in 2002 on "Heise Newsticker". For more informations visit:</p> <p><a href="http://www.heise.de/newsticker/data/wst-28.01.02-003/" rel="nofollow">http://www.heise.de/newsticker/data/wst-28.01.02-003/</a> <a href="http://xxx.uni-augsburg.de/format/cond-mat/0108530" rel="nofollow">http://xxx.uni-augsburg.de/format/cond-mat/0108530</a></p> Lightweight XML constructor and reader (Python) 2002-10-18T02:53:37-07:00Dirk Holtwickhttp://code.activestate.com/recipes/users/636691/http://code.activestate.com/recipes/157358-lightweight-xml-constructor-and-reader/ <p style="color: grey"> Python recipe 157358 by <a href="/recipes/users/636691/">Dirk Holtwick</a> (<a href="/recipes/tags/xml/">xml</a>). </p> <p>XML is a wonderful buzzword, so clients often like to have exports of data in that format. But as a programmer you may not like to fiddle around with various XML Parsers. Here is a very easy solution, that doesn't offer all capabilities of XML but sufficient stuff for creating valid XML outputs and read them later.</p> Windows registry for dummies (Python) 2002-08-23T06:37:57-07:00Dirk Holtwickhttp://code.activestate.com/recipes/users/636691/http://code.activestate.com/recipes/146305-windows-registry-for-dummies/ <p style="color: grey"> Python recipe 146305 by <a href="/recipes/users/636691/">Dirk Holtwick</a> (<a href="/recipes/tags/sysadmin/">sysadmin</a>). </p> <p>Okay, using the windows registry became easier with the newest versions of Python but do you exctly know where the keys have to be placed? You just want to store some data for your progam in the windows registry without fiddling around with SetValue() etc. Have a look at this class:</p>