<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>Snipplr</title>
    <description>Recent snippets posted on Snipplr.com</description>
    <link>https://snipplr.com/</link>
    <lastBuildDate>Tue, 09 Jun 2026 09:07:57 +0000</lastBuildDate>
    <item>
      <title>(Python) python pretty date print - magicrebirth</title>
      <link>https://snipplr.com/view/73411/python-pretty-date-print</link>
      <description>&lt;p&gt;&lt;/p&gt;</description>
      <pubDate>Tue, 14 Jan 2014 01:45:08 UTC</pubDate>
      <guid>https://snipplr.com/view/73411/python-pretty-date-print</guid>
    </item>
    <item>
      <title>(Python) Indenting source code in python - magicrebirth</title>
      <link>https://snipplr.com/view/57154/indenting-source-code-in-python</link>
      <description>&lt;p&gt;&lt;/p&gt;</description>
      <pubDate>Tue, 26 Jul 2011 21:08:09 UTC</pubDate>
      <guid>https://snipplr.com/view/57154/indenting-source-code-in-python</guid>
    </item>
    <item>
      <title>(Python) Statistical String Comparison - magicrebirth</title>
      <link>https://snipplr.com/view/57051/statistical-string-comparison</link>
      <description>&lt;p&gt;http://docs.python.org/library/difflib.html&lt;/p&gt;</description>
      <pubDate>Fri, 22 Jul 2011 23:06:05 UTC</pubDate>
      <guid>https://snipplr.com/view/57051/statistical-string-comparison</guid>
    </item>
    <item>
      <title>(Python) Colorizing Python Source Using the Built-in Tokenizer - magicrebirth</title>
      <link>https://snipplr.com/view/56858/colorizing-python-source-using-the-builtin-tokenizer</link>
      <description>&lt;p&gt;You need to convert Python source code into HTML markup, rendering comments, keywords, operators, and numeric and string literals in different colors.&#13;
tokenize.generate_tokens does most of the work. We just need to loop over all tokens it finds, to output them with appropriate colorization:&lt;/p&gt;</description>
      <pubDate>Tue, 19 Jul 2011 18:01:26 UTC</pubDate>
      <guid>https://snipplr.com/view/56858/colorizing-python-source-using-the-builtin-tokenizer</guid>
    </item>
    <item>
      <title>(Python) RGB Gradation Chart Generator - magicrebirth</title>
      <link>https://snipplr.com/view/56710/rgb-gradation-chart-generator</link>
      <description>&lt;p&gt;[from the author's website]&#13;
I wrote this to better understand the relationship between RGB colors. Running it will generate a fairly large HTML file with all sorts of color transitions on it so you can see what is happening as colors are tweaked in different ways.&lt;/p&gt;</description>
      <pubDate>Sun, 17 Jul 2011 20:22:21 UTC</pubDate>
      <guid>https://snipplr.com/view/56710/rgb-gradation-chart-generator</guid>
    </item>
    <item>
      <title>(Python) RGB Color Gradation Function - magicrebirth</title>
      <link>https://snipplr.com/view/56709/rgb-color-gradation-function</link>
      <description>&lt;p&gt;&lt;/p&gt;</description>
      <pubDate>Sun, 17 Jul 2011 20:15:43 UTC</pubDate>
      <guid>https://snipplr.com/view/56709/rgb-color-gradation-function</guid>
    </item>
    <item>
      <title>(Python) Counting elements in a list - magicrebirth</title>
      <link>https://snipplr.com/view/55137/counting-elements-in-a-list</link>
      <description>&lt;p&gt;&lt;/p&gt;</description>
      <pubDate>Sat, 11 Jun 2011 00:49:15 UTC</pubDate>
      <guid>https://snipplr.com/view/55137/counting-elements-in-a-list</guid>
    </item>
    <item>
      <title>(Python) Extracting a URL in Python - magicrebirth</title>
      <link>https://snipplr.com/view/55134/extracting-a-url-in-python</link>
      <description>&lt;p&gt;&lt;/p&gt;</description>
      <pubDate>Fri, 10 Jun 2011 23:43:42 UTC</pubDate>
      <guid>https://snipplr.com/view/55134/extracting-a-url-in-python</guid>
    </item>
    <item>
      <title>(Python) Ways to Move up and Down the dir structure in Python - magicrebirth</title>
      <link>https://snipplr.com/view/53250/ways-to-move-up-and-down-the-dir-structure-in-python</link>
      <description>&lt;p&gt;&lt;/p&gt;</description>
      <pubDate>Mon, 09 May 2011 23:10:03 UTC</pubDate>
      <guid>https://snipplr.com/view/53250/ways-to-move-up-and-down-the-dir-structure-in-python</guid>
    </item>
    <item>
      <title>(Python) Python: rename a file - magicrebirth</title>
      <link>https://snipplr.com/view/51486/python-rename-a-file</link>
      <description>&lt;p&gt;&lt;/p&gt;</description>
      <pubDate>Mon, 04 Apr 2011 00:06:08 UTC</pubDate>
      <guid>https://snipplr.com/view/51486/python-rename-a-file</guid>
    </item>
    <item>
      <title>(Python) Getting the difference between two lists - Python - magicrebirth</title>
      <link>https://snipplr.com/view/51138/getting-the-difference-between-two-lists--python</link>
      <description>&lt;p&gt;&lt;/p&gt;</description>
      <pubDate>Sat, 26 Mar 2011 03:19:27 UTC</pubDate>
      <guid>https://snipplr.com/view/51138/getting-the-difference-between-two-lists--python</guid>
    </item>
    <item>
      <title>(Python) CSV reading in python - magicrebirth</title>
      <link>https://snipplr.com/view/50966/csv-reading-in-python</link>
      <description>&lt;p&gt;&lt;/p&gt;</description>
      <pubDate>Tue, 22 Mar 2011 22:23:48 UTC</pubDate>
      <guid>https://snipplr.com/view/50966/csv-reading-in-python</guid>
    </item>
    <item>
      <title>(Python) recursion in scheme and python - magicrebirth</title>
      <link>https://snipplr.com/view/50828/recursion-in-scheme-and-python</link>
      <description>&lt;p&gt;&lt;/p&gt;</description>
      <pubDate>Sat, 19 Mar 2011 01:56:08 UTC</pubDate>
      <guid>https://snipplr.com/view/50828/recursion-in-scheme-and-python</guid>
    </item>
    <item>
      <title>(Python) Best way to choose a random file from a directory - magicrebirth</title>
      <link>https://snipplr.com/view/49167/best-way-to-choose-a-random-file-from-a-directory</link>
      <description>&lt;p&gt;&lt;/p&gt;</description>
      <pubDate>Fri, 18 Feb 2011 00:09:51 UTC</pubDate>
      <guid>https://snipplr.com/view/49167/best-way-to-choose-a-random-file-from-a-directory</guid>
    </item>
    <item>
      <title>(Python) RDFlib: access a triple store in 5 lines of code - magicrebirth</title>
      <link>https://snipplr.com/view/48617/rdflib-access-a-triple-store-in-5-lines-of-code</link>
      <description>&lt;p&gt;Note that in the example the 'sleepycat' backend is used ( Oracle Berkeley DB, which requires the ''bsddb3'' python bindings). If you don't have that installed you can just remove that directive and the triples will be loaded in memory.....&lt;/p&gt;</description>
      <pubDate>Tue, 08 Feb 2011 23:14:30 UTC</pubDate>
      <guid>https://snipplr.com/view/48617/rdflib-access-a-triple-store-in-5-lines-of-code</guid>
    </item>
    <item>
      <title>(Python) Python generator - magicrebirth</title>
      <link>https://snipplr.com/view/46831/python-generator</link>
      <description>&lt;p&gt;&lt;/p&gt;</description>
      <pubDate>Mon, 10 Jan 2011 01:48:28 UTC</pubDate>
      <guid>https://snipplr.com/view/46831/python-generator</guid>
    </item>
    <item>
      <title>(Python) How to Write a Spelling Corrector (in 21 lines) - magicrebirth</title>
      <link>https://snipplr.com/view/46794/how-to-write-a-spelling-corrector-in-21-lines</link>
      <description>&lt;p&gt;Requires an external file for the statistical algorithm... (big.txt)&lt;/p&gt;</description>
      <pubDate>Sun, 09 Jan 2011 02:54:14 UTC</pubDate>
      <guid>https://snipplr.com/view/46794/how-to-write-a-spelling-corrector-in-21-lines</guid>
    </item>
    <item>
      <title>(Python) Check time difference between now and specified time - magicrebirth</title>
      <link>https://snipplr.com/view/44970/check-time-difference-between-now-and-specified-time</link>
      <description>&lt;p&gt;&lt;/p&gt;</description>
      <pubDate>Sun, 28 Nov 2010 00:27:59 UTC</pubDate>
      <guid>https://snipplr.com/view/44970/check-time-difference-between-now-and-specified-time</guid>
    </item>
    <item>
      <title>(Python) From a list containing tree info, generare a tree in dict format - magicrebirth</title>
      <link>https://snipplr.com/view/43903/from-a-list-containing-tree-info-generare-a-tree-in-dict-format</link>
      <description>&lt;p&gt;The resulting tree is represented through a dict where each father gets a key (with all the children as args)&lt;/p&gt;</description>
      <pubDate>Wed, 10 Nov 2010 22:35:08 UTC</pubDate>
      <guid>https://snipplr.com/view/43903/from-a-list-containing-tree-info-generare-a-tree-in-dict-format</guid>
    </item>
    <item>
      <title>(Python) Creating directories programmatically - magicrebirth</title>
      <link>https://snipplr.com/view/43554/creating-directories-programmatically</link>
      <description>&lt;p&gt;save as a file and run....&lt;/p&gt;</description>
      <pubDate>Thu, 04 Nov 2010 20:27:19 UTC</pubDate>
      <guid>https://snipplr.com/view/43554/creating-directories-programmatically</guid>
    </item>
    <item>
      <title>(Python) How to Add Locations to Python Path in Django - magicrebirth</title>
      <link>https://snipplr.com/view/42518/how-to-add-locations-to-python-path-in-django</link>
      <description>&lt;p&gt;&lt;/p&gt;</description>
      <pubDate>Tue, 19 Oct 2010 05:52:11 UTC</pubDate>
      <guid>https://snipplr.com/view/42518/how-to-add-locations-to-python-path-in-django</guid>
    </item>
    <item>
      <title>(Python) Global variables in Python - magicrebirth</title>
      <link>https://snipplr.com/view/41106/global-variables-in-python</link>
      <description>&lt;p&gt;&lt;/p&gt;</description>
      <pubDate>Tue, 28 Sep 2010 22:24:50 UTC</pubDate>
      <guid>https://snipplr.com/view/41106/global-variables-in-python</guid>
    </item>
    <item>
      <title>(Python) File overwrite and append in python - magicrebirth</title>
      <link>https://snipplr.com/view/40878/file-overwrite-and-append-in-python</link>
      <description>&lt;p&gt;&lt;/p&gt;</description>
      <pubDate>Wed, 22 Sep 2010 02:20:39 UTC</pubDate>
      <guid>https://snipplr.com/view/40878/file-overwrite-and-append-in-python</guid>
    </item>
    <item>
      <title>(Python) String literals that span multiple lines - magicrebirth</title>
      <link>https://snipplr.com/view/40571/string-literals-that-span-multiple-lines</link>
      <description>&lt;p&gt;&lt;/p&gt;</description>
      <pubDate>Thu, 16 Sep 2010 08:29:41 UTC</pubDate>
      <guid>https://snipplr.com/view/40571/string-literals-that-span-multiple-lines</guid>
    </item>
    <item>
      <title>(Python) How do I copy an object inÂ Python? - magicrebirth</title>
      <link>https://snipplr.com/view/40569/how-do-i-copy-an-object-inpython</link>
      <description>&lt;p&gt;&lt;/p&gt;</description>
      <pubDate>Thu, 16 Sep 2010 07:43:13 UTC</pubDate>
      <guid>https://snipplr.com/view/40569/how-do-i-copy-an-object-inpython</guid>
    </item>
    <item>
      <title>(Python) changing default version when updating Python on Mac - magicrebirth</title>
      <link>https://snipplr.com/view/39372/changing-default-version-when-updating-python-on-mac</link>
      <description>&lt;p&gt;&lt;/p&gt;</description>
      <pubDate>Sat, 21 Aug 2010 05:07:48 UTC</pubDate>
      <guid>https://snipplr.com/view/39372/changing-default-version-when-updating-python-on-mac</guid>
    </item>
    <item>
      <title>(Python) Start a quick webserver from any directory: - magicrebirth</title>
      <link>https://snipplr.com/view/38193/start-a-quick-webserver-from-any-directory</link>
      <description>&lt;p&gt;&lt;/p&gt;</description>
      <pubDate>Mon, 02 Aug 2010 08:05:46 UTC</pubDate>
      <guid>https://snipplr.com/view/38193/start-a-quick-webserver-from-any-directory</guid>
    </item>
    <item>
      <title>(Python) Count items and sort by incidence - magicrebirth</title>
      <link>https://snipplr.com/view/37719/count-items-and-sort-by-incidence</link>
      <description>&lt;p&gt;&lt;/p&gt;</description>
      <pubDate>Thu, 22 Jul 2010 03:33:15 UTC</pubDate>
      <guid>https://snipplr.com/view/37719/count-items-and-sort-by-incidence</guid>
    </item>
    <item>
      <title>(Python) RDFLIB: playing with URIRef objects - magicrebirth</title>
      <link>https://snipplr.com/view/37174/rdflib-playing-with-uriref-objects</link>
      <description>&lt;p&gt;&lt;/p&gt;</description>
      <pubDate>Tue, 13 Jul 2010 03:29:20 UTC</pubDate>
      <guid>https://snipplr.com/view/37174/rdflib-playing-with-uriref-objects</guid>
    </item>
    <item>
      <title>(Python) Reload code in console - magicrebirth</title>
      <link>https://snipplr.com/view/37160/reload-code-in-console</link>
      <description>&lt;p&gt;&lt;/p&gt;</description>
      <pubDate>Mon, 12 Jul 2010 22:46:43 UTC</pubDate>
      <guid>https://snipplr.com/view/37160/reload-code-in-console</guid>
    </item>
    <item>
      <title>(Python) Open URL - Python - magicrebirth</title>
      <link>https://snipplr.com/view/36847/open-url--python</link>
      <description>&lt;p&gt;&lt;/p&gt;</description>
      <pubDate>Wed, 07 Jul 2010 20:40:19 UTC</pubDate>
      <guid>https://snipplr.com/view/36847/open-url--python</guid>
    </item>
    <item>
      <title>(Python) sorting a dictionary - magicrebirth</title>
      <link>https://snipplr.com/view/34623/sorting-a-dictionary</link>
      <description>&lt;p&gt;Dictionaries cant be sorted, so you need to transform it into a list and sort that one!&lt;/p&gt;</description>
      <pubDate>Mon, 17 May 2010 08:03:48 UTC</pubDate>
      <guid>https://snipplr.com/view/34623/sorting-a-dictionary</guid>
    </item>
    <item>
      <title>(Python) dict.items vs dict.iteritems - magicrebirth</title>
      <link>https://snipplr.com/view/34617/dictitems-vs-dictiteritems</link>
      <description>&lt;p&gt;When is it appropriate to use dict.items() vs dict.iteritems?&#13;
&#13;
&#13;
Also, when is it appropriate to use range() vs xrange(). From my&#13;
understanding, xrange() essentially gives you an iterator across a&#13;
range, so it should be used when iterating. Should you only use&#13;
range() when want to physically store the range as a list?&lt;/p&gt;</description>
      <pubDate>Mon, 17 May 2010 06:49:51 UTC</pubDate>
      <guid>https://snipplr.com/view/34617/dictitems-vs-dictiteritems</guid>
    </item>
    <item>
      <title>(Python) 'Dictionary Comprehensions' - magicrebirth</title>
      <link>https://snipplr.com/view/34616/dictionary-comprehensions</link>
      <description>&lt;p&gt;Although Python doesn't have built-in dictionary comprehensions, you can do something pretty close with little mess or code. Just use .iteritems() to turn your dict into a list, throw it in a generator expression (or list comprehension), and then cast that list back into a dict.&#13;
&#13;
For example, say I have a dictionary of name:email pairs, and I want to create a dictionary of name:is_email_at_a_dot_com pairs:&lt;/p&gt;</description>
      <pubDate>Mon, 17 May 2010 06:34:30 UTC</pubDate>
      <guid>https://snipplr.com/view/34616/dictionary-comprehensions</guid>
    </item>
    <item>
      <title>(Python) Dicts to Lists / Lists to Dicts - magicrebirth</title>
      <link>https://snipplr.com/view/34615/dicts-to-lists--lists-to-dicts</link>
      <description>&lt;p&gt;Turning a dictionary into a list or an iterator is easy. To get a list of keys, you can just cast the dict into a list. It's cleaner, though to call .keys() on the dictionary to get a list of the keys, or .iterkeys() to get an iterator. Similarly, you can call .values() or .itervalues() to get a list or iterator of dictionary values. Remember though, that dicts are inherently unordered and so these values won't be in any meaningful order.&#13;
&#13;
To preserve both keys and values, you can turn a dict into a list or iterator of 2-item tuples by using .items() or .iteritems(). This is something that you'll probably do a lot, and isn't very exciting:&lt;/p&gt;</description>
      <pubDate>Mon, 17 May 2010 06:33:09 UTC</pubDate>
      <guid>https://snipplr.com/view/34615/dicts-to-lists--lists-to-dicts</guid>
    </item>
    <item>
      <title>(Python) Creating Dictionaries - magicrebirth</title>
      <link>https://snipplr.com/view/34614/creating-dictionaries</link>
      <description>&lt;p&gt;Any keyword arguments you pass to the dict constructor are added to the newly created dictionary before returning. Of course, you are limited to the keys that can be made into keyword arguments: valid Python variable names.&lt;/p&gt;</description>
      <pubDate>Mon, 17 May 2010 06:30:32 UTC</pubDate>
      <guid>https://snipplr.com/view/34614/creating-dictionaries</guid>
    </item>
    <item>
      <title>(Python) consume xml from RestFul webservices - magicrebirth</title>
      <link>https://snipplr.com/view/29583/consume-xml-from-restful-webservices</link>
      <description>&lt;p&gt;ElementTree is provided as part of the standard Python libs. ElementTree is pure python, and cElementTree is the faster C implementation:&#13;
&#13;
Here's an example usage, where I'm consuming xml from a RESTful web service:&lt;/p&gt;</description>
      <pubDate>Thu, 11 Mar 2010 02:01:49 UTC</pubDate>
      <guid>https://snipplr.com/view/29583/consume-xml-from-restful-webservices</guid>
    </item>
    <item>
      <title>(Python) python\'s random - magicrebirth</title>
      <link>https://snipplr.com/view/29455/pythons-random</link>
      <description>&lt;p&gt;&lt;/p&gt;</description>
      <pubDate>Tue, 09 Mar 2010 00:55:38 UTC</pubDate>
      <guid>https://snipplr.com/view/29455/pythons-random</guid>
    </item>
    <item>
      <title>(Python) Jython first run - magicrebirth</title>
      <link>https://snipplr.com/view/27999/jython-first-run</link>
      <description>&lt;p&gt;http://www.jython.org/docs/index.html&lt;/p&gt;</description>
      <pubDate>Tue, 09 Feb 2010 01:24:43 UTC</pubDate>
      <guid>https://snipplr.com/view/27999/jython-first-run</guid>
    </item>
    <item>
      <title>(Python) Wait function - python - magicrebirth</title>
      <link>https://snipplr.com/view/27238/wait-function--python</link>
      <description>&lt;p&gt;&lt;/p&gt;</description>
      <pubDate>Thu, 28 Jan 2010 09:36:28 UTC</pubDate>
      <guid>https://snipplr.com/view/27238/wait-function--python</guid>
    </item>
    <item>
      <title>(Python) Django: instantiating M2M-through models - magicrebirth</title>
      <link>https://snipplr.com/view/27156/django-instantiating-m2mthrough-models</link>
      <description>&lt;p&gt;Now that you have set up your ManyToManyField to use your intermediary model (Membership, in this case), you're ready to start creating some many-to-many relationships. You do this by creating instances of the intermediate model:&lt;/p&gt;</description>
      <pubDate>Wed, 27 Jan 2010 07:21:26 UTC</pubDate>
      <guid>https://snipplr.com/view/27156/django-instantiating-m2mthrough-models</guid>
    </item>
    <item>
      <title>(Python) Python: simple REgex  example - magicrebirth</title>
      <link>https://snipplr.com/view/26620/python-simple-regex--example</link>
      <description>&lt;p&gt;&lt;/p&gt;</description>
      <pubDate>Sun, 17 Jan 2010 11:27:47 UTC</pubDate>
      <guid>https://snipplr.com/view/26620/python-simple-regex--example</guid>
    </item>
    <item>
      <title>(Python) Open an RDF graph - magicrebirth</title>
      <link>https://snipplr.com/view/25275/open-an-rdf-graph</link>
      <description>&lt;p&gt;&lt;/p&gt;</description>
      <pubDate>Tue, 22 Dec 2009 15:43:19 UTC</pubDate>
      <guid>https://snipplr.com/view/25275/open-an-rdf-graph</guid>
    </item>
    <item>
      <title>(Python) Query an RDF graph - magicrebirth</title>
      <link>https://snipplr.com/view/25274/query-an-rdf-graph</link>
      <description>&lt;p&gt;&lt;/p&gt;</description>
      <pubDate>Tue, 22 Dec 2009 15:42:55 UTC</pubDate>
      <guid>https://snipplr.com/view/25274/query-an-rdf-graph</guid>
    </item>
    <item>
      <title>(Python) Python: Introspection function - magicrebirth</title>
      <link>https://snipplr.com/view/25272/python-introspection-function</link>
      <description>&lt;p&gt;The info function is designed to be used by you, the programmer, while working in the Python IDE. It takes any object that has functions or methods (like a module, which has functions, or a list, which has methods) and prints out the functions and their doc strings.&lt;/p&gt;</description>
      <pubDate>Tue, 22 Dec 2009 15:41:06 UTC</pubDate>
      <guid>https://snipplr.com/view/25272/python-introspection-function</guid>
    </item>
    <item>
      <title>(Python) Iterating over multiple sequences at the same time - magicrebirth</title>
      <link>https://snipplr.com/view/25269/iterating-over-multiple-sequences-at-the-same-time</link>
      <description>&lt;p&gt;&lt;/p&gt;</description>
      <pubDate>Tue, 22 Dec 2009 15:39:07 UTC</pubDate>
      <guid>https://snipplr.com/view/25269/iterating-over-multiple-sequences-at-the-same-time</guid>
    </item>
    <item>
      <title>(Python) Catching and throwing exceptions - magicrebirth</title>
      <link>https://snipplr.com/view/25268/catching-and-throwing-exceptions</link>
      <description>&lt;p&gt;&lt;/p&gt;</description>
      <pubDate>Tue, 22 Dec 2009 15:38:36 UTC</pubDate>
      <guid>https://snipplr.com/view/25268/catching-and-throwing-exceptions</guid>
    </item>
    <item>
      <title>(Python) Python: execute files from the interpreter - magicrebirth</title>
      <link>https://snipplr.com/view/25264/python-execute-files-from-the-interpreter</link>
      <description>&lt;p&gt;Scripts can also be executed from within the interpreter using the execfile(script) function built in to Python. &#13;
The following example shows a script being executed using the execfile() function:&lt;/p&gt;</description>
      <pubDate>Tue, 22 Dec 2009 15:35:26 UTC</pubDate>
      <guid>https://snipplr.com/view/25264/python-execute-files-from-the-interpreter</guid>
    </item>
    <item>
      <title>(Python) Python: checking the type of an object - magicrebirth</title>
      <link>https://snipplr.com/view/25263/python-checking-the-type-of-an-object</link>
      <description>&lt;p&gt;&lt;/p&gt;</description>
      <pubDate>Tue, 22 Dec 2009 15:34:34 UTC</pubDate>
      <guid>https://snipplr.com/view/25263/python-checking-the-type-of-an-object</guid>
    </item>
    <item>
      <title>(Python) Python: formatting strings - magicrebirth</title>
      <link>https://snipplr.com/view/25262/python-formatting-strings</link>
      <description>&lt;p&gt;Python allows for strings to be formatted using a predefined format string with a list of variables. &#13;
The following is an example of using multiple format strings to display the same data:&lt;/p&gt;</description>
      <pubDate>Tue, 22 Dec 2009 15:34:09 UTC</pubDate>
      <guid>https://snipplr.com/view/25262/python-formatting-strings</guid>
    </item>
  </channel>
</rss>
