Popular recipes by Robin Parmar http://code.activestate.com/recipes/users/99666/2007-08-10T14:27:52-07:00ActiveState Code RecipesFriendly Readable ID Strings (Python) 2007-08-10T14:27:52-07:00Robin Parmarhttp://code.activestate.com/recipes/users/99666/http://code.activestate.com/recipes/526619-friendly-readable-id-strings/ <p style="color: grey"> Python recipe 526619 by <a href="/recipes/users/99666/">Robin Parmar</a> (<a href="/recipes/tags/algorithms/">algorithms</a>). Revision 3. </p> <p>One often needs unique ID strings to tag processes, threads, files or anything else that might be created in quantity. Traditionally these are created based on PIDs or similar system values. But it is not easy to visually recognise these strings, which makes debugging more difficult than it need be. This recipe creates readable and pronounceable ID strings that are much easier to work with.</p> Line Of Code Counter (Python) 2007-08-09T16:42:45-07:00Robin Parmarhttp://code.activestate.com/recipes/users/99666/http://code.activestate.com/recipes/527746-line-of-code-counter/ <p style="color: grey"> Python recipe 527746 by <a href="/recipes/users/99666/">Robin Parmar</a> (<a href="/recipes/tags/files/">files</a>). </p> <p>This simple function counts Lines Of Code in Python files in two ways: maximal size (source LOC) with blank lines and comments, minimal size (logical LOC) stripping same. It includes a simplified version of my directory tree walker from <a href="http://code.activestate.com/recipes/52664/">recipe 52664</a>.</p> Smart pluralisation (English) (Python) 2001-10-16T11:45:09-07:00Robin Parmarhttp://code.activestate.com/recipes/users/99666/http://code.activestate.com/recipes/82102-smart-pluralisation-english/ <p style="color: grey"> Python recipe 82102 by <a href="/recipes/users/99666/">Robin Parmar</a> (<a href="/recipes/tags/text/">text</a>). </p> <p>Smart pluralisation function that provides more intelligence than simply adding an 's' to the end of a word.</p> hexify (Python) 2001-11-05T18:51:51-08:00Robin Parmarhttp://code.activestate.com/recipes/users/99666/http://code.activestate.com/recipes/82748-hexify/ <p style="color: grey"> Python recipe 82748 by <a href="/recipes/users/99666/">Robin Parmar</a> (<a href="/recipes/tags/files/">files</a>). Revision 4. </p> <p>Hexify is a hex dump utility handy for viewing binary files at the command-prompt.</p> Dynamically change the Python system path (Python) 2001-10-16T17:04:08-07:00Robin Parmarhttp://code.activestate.com/recipes/users/99666/http://code.activestate.com/recipes/52662-dynamically-change-the-python-system-path/ <p style="color: grey"> Python recipe 52662 by <a href="/recipes/users/99666/">Robin Parmar</a> (<a href="/recipes/tags/sysadmin/">sysadmin</a>). Revision 3. </p> <p>Adds the specified path to the Python system path if it is not already there. Takes into account terminating slashes and case (on Windows).</p> <p>Returns -1 if the path does not exist, 1 if it was added, and 0 if it was not (because it is already present).</p> Flexible directory walking (Python) 2001-06-25T23:27:51-07:00Robin Parmarhttp://code.activestate.com/recipes/users/99666/http://code.activestate.com/recipes/52664-flexible-directory-walking/ <p style="color: grey"> Python recipe 52664 by <a href="/recipes/users/99666/">Robin Parmar</a> (<a href="/recipes/tags/files/">files</a>). Revision 2. </p> <p>This function walks a directory tree starting at a specified root folder, and returns a list of all of the files (and optionally folders) that match our pattern(s).</p> Versioning file names (Python) 2001-06-25T23:25:47-07:00Robin Parmarhttp://code.activestate.com/recipes/users/99666/http://code.activestate.com/recipes/52663-versioning-file-names/ <p style="color: grey"> Python recipe 52663 by <a href="/recipes/users/99666/">Robin Parmar</a> (<a href="/recipes/tags/files/">files</a>). Revision 3. </p> <p>If the specified file exists, it is versioned by appending to the extension a three-digit number, starting with "000".</p> Simple tests using Exceptions (Python) 2001-06-25T23:23:58-07:00Robin Parmarhttp://code.activestate.com/recipes/users/99666/http://code.activestate.com/recipes/52660-simple-tests-using-exceptions/ <p style="color: grey"> Python recipe 52660 by <a href="/recipes/users/99666/">Robin Parmar</a> (<a href="/recipes/tags/algorithms/">algorithms</a>). Revision 2. </p> <p>Exceptions provide very handy ways of performing simple tests. For example, if you want to know if the contents of a string represent an integer, why not just try to convert it? That's what IsInt() does.</p> Parsing a full file specification. (Python) 2001-10-16T16:26:54-07:00Robin Parmarhttp://code.activestate.com/recipes/users/99666/http://code.activestate.com/recipes/52661-parsing-a-full-file-specification/ <p style="color: grey"> Python recipe 52661 by <a href="/recipes/users/99666/">Robin Parmar</a> (<a href="/recipes/tags/files/">files</a>). Revision 2. </p> <p>This function parses a full file specification into tuple of: a) list of drive and folders b) file name c) (last) file extension (including dot)</p>