<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Snipplr</title>
<link>http://snipplr.com/language/python/tags/python</link>
<description>Recent snippets posted on Snipplr.com</description>
<language>en-us</language>
<pubDate>Sat, 11 Oct 2008 12:18:02 GMT</pubDate>
<item>
<title>(Python) Download all *.rm files from a site link or and xml link having ram files - hemanthhm</title>
<link>http://snipplr.com/view/8882/download-all-rm-files-from-a-site-link-or-and-xml-link-having-ram-files/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Tue, 07 Oct 2008 14:46:08 GMT</pubDate>
<guid>http://snipplr.com/view/8882/download-all-rm-files-from-a-site-link-or-and-xml-link-having-ram-files/</guid>
</item>
<item>
<title>(Python) Running Doctest/Docutils - stoyan</title>
<link>http://snipplr.com/view/8703/running-doctestdocutils/</link>
<description><![CDATA[ <p>This is going to run all doctests for all methods in a module. Doctests are a beautiful thing. 
Note: doctest will only complain if a test fails. If you see on output then all your tests must have passed.</p> ]]></description>
<pubDate>Mon, 29 Sep 2008 21:42:36 GMT</pubDate>
<guid>http://snipplr.com/view/8703/running-doctestdocutils/</guid>
</item>
<item>
<title>(Python) pickle(cPickle) vs numpy tofile/fromfile - tkf</title>
<link>http://snipplr.com/view/8632/picklecpickle-vs-numpy-tofilefromfile/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Fri, 26 Sep 2008 12:10:14 GMT</pubDate>
<guid>http://snipplr.com/view/8632/picklecpickle-vs-numpy-tofilefromfile/</guid>
</item>
<item>
<title>(Python) Generate numbered icons with PIL - stoyan</title>
<link>http://snipplr.com/view/8587/generate-numbered-icons-with-pil/</link>
<description><![CDATA[ <p>I had an icon representing a little blue dot and needed to create 100 copies each with a number in them. 
Python saves the day yet again.</p> ]]></description>
<pubDate>Thu, 25 Sep 2008 03:59:33 GMT</pubDate>
<guid>http://snipplr.com/view/8587/generate-numbered-icons-with-pil/</guid>
</item>
<item>
<title>(Python) Python: Basic Feedparser example for Os X.5 - chrisaiv</title>
<link>http://snipplr.com/view/8511/python-basic-feedparser-example-for-os-x5/</link>
<description><![CDATA[ <p>Using terminal, download feedparser, you can specify a specific version if preferred:  sudo easy_install "feedparser==4.1"

Once installed, create a new pythonFile.py and paste this code and Run</p> ]]></description>
<pubDate>Sat, 20 Sep 2008 16:45:07 GMT</pubDate>
<guid>http://snipplr.com/view/8511/python-basic-feedparser-example-for-os-x5/</guid>
</item>
<item>
<title>(Python) Git and XCode: A git build number script - sudarkoff</title>
<link>http://snipplr.com/view/8350/git-and-xcode-a-git-build-number-script/</link>
<description><![CDATA[ <p>The script was modified slightly based on comments.</p> ]]></description>
<pubDate>Thu, 11 Sep 2008 14:05:49 GMT</pubDate>
<guid>http://snipplr.com/view/8350/git-and-xcode-a-git-build-number-script/</guid>
</item>
<item>
<title>(Python) IMAP Backup Script - denilw</title>
<link>http://snipplr.com/view/7955/imap-backup-script/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Wed, 20 Aug 2008 22:36:00 GMT</pubDate>
<guid>http://snipplr.com/view/7955/imap-backup-script/</guid>
</item>
<item>
<title>(Python) Post to Twitter from Shell - Python Version - nate_smith</title>
<link>http://snipplr.com/view/7870/post-to-twitter-from-shell--python-version/</link>
<description><![CDATA[ <p>inspired by http://snipplr.com/view/6594/post-to-twitter-from-the-shell/ . I just rewrote it in Python because I didn't want to install a Ruby interpreter :)

use `chmod +x tweet.py` to run it as `./tweet.py` instead of `python tweet.py`</p> ]]></description>
<pubDate>Thu, 14 Aug 2008 09:36:26 GMT</pubDate>
<guid>http://snipplr.com/view/7870/post-to-twitter-from-shell--python-version/</guid>
</item>
<item>
<title>(Python) Python make url address to Tinyurl - huacnlee</title>
<link>http://snipplr.com/view/7604/python-make-url-address-to-tinyurl/</link>
<description><![CDATA[ <p>Python make url address to Tinyurl in article content like Twitter message</p> ]]></description>
<pubDate>Wed, 30 Jul 2008 13:41:18 GMT</pubDate>
<guid>http://snipplr.com/view/7604/python-make-url-address-to-tinyurl/</guid>
</item>
<item>
<title>(Python) Mp3 downloader from feeds - panquetofobia</title>
<link>http://snipplr.com/view/7595/mp3-downloader-from-feeds/</link>
<description><![CDATA[ <p>This script downloads all mp3 links from given rss/atom feeds.
I wrote this to learn python so I'm sure there are better ways to do this.
Depends on wget.</p> ]]></description>
<pubDate>Tue, 29 Jul 2008 21:54:56 GMT</pubDate>
<guid>http://snipplr.com/view/7595/mp3-downloader-from-feeds/</guid>
</item>
<item>
<title>(Python) remove diacritics - scarfboy</title>
<link>http://snipplr.com/view/7355/remove-diacritics/</link>
<description><![CDATA[ <p>Useful when creating canonical forms of strings for indexing.</p> ]]></description>
<pubDate>Thu, 17 Jul 2008 06:51:47 GMT</pubDate>
<guid>http://snipplr.com/view/7355/remove-diacritics/</guid>
</item>
<item>
<title>(Python) Creating and removing files and dirs with Python OS module - chombee</title>
<link>http://snipplr.com/view/7318/creating-and-removing-files-and-dirs-with-python-os-module/</link>
<description><![CDATA[ <p>Effbot's page on the os module: http://effbot.org/librarybook/os.htm

The os module has lots of methods for dealing with files and directories: http://docs.python.org/lib/os-file-dir.html

The shutil module: http://docs.python.org/lib/module-shutil.html</p> ]]></description>
<pubDate>Tue, 15 Jul 2008 20:44:02 GMT</pubDate>
<guid>http://snipplr.com/view/7318/creating-and-removing-files-and-dirs-with-python-os-module/</guid>
</item>
<item>
<title>(Python) Listing directories in Python - chombee</title>
<link>http://snipplr.com/view/7187/listing-directories-in-python/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Wed, 09 Jul 2008 13:57:08 GMT</pubDate>
<guid>http://snipplr.com/view/7187/listing-directories-in-python/</guid>
</item>
<item>
<title>(Python) Name Mangling of Python Private Variables - ishikawa</title>
<link>http://snipplr.com/view/7027/name-mangling-of-python-private-variables/</link>
<description><![CDATA[ <p>Python: Private Variables
http://docs.python.org/tut/node11.html#SECTION0011600000000000000000

Any identifier of the form __spam (at least two leading underscores, at most one trailing underscore) is textually replaced with _classname__spam, where classname is the current class name with leading underscore(s) stripped.

Truncation may occur when the mangled name would be longer than 255 characters. When the class name consists of only underscores, no mangling occurs.</p> ]]></description>
<pubDate>Mon, 30 Jun 2008 10:08:15 GMT</pubDate>
<guid>http://snipplr.com/view/7027/name-mangling-of-python-private-variables/</guid>
</item>
<item>
<title>(Python) Unit tests with Python - chombee</title>
<link>http://snipplr.com/view/6739/unit-tests-with-python/</link>
<description><![CDATA[ <p>Test-first programming, in which you write the unit tests first with the unittest module and then work on the code until it passes all the tests, seems like a good substitute for writing interfaces or documentation first. The unit tests are like an API, describing the interface of the code being tested. And they lend themselves well to refactoring.

This is a first attempt at a unit test for the messager.py module posted earlier.</p> ]]></description>
<pubDate>Mon, 16 Jun 2008 10:35:25 GMT</pubDate>
<guid>http://snipplr.com/view/6739/unit-tests-with-python/</guid>
</item>
<item>
<title>(Python) Messager pattern from Panda3D - chombee</title>
<link>http://snipplr.com/view/6650/messager-pattern-from-panda3d/</link>
<description><![CDATA[ <p>This is my implementation of the messager pattern used by Panda3D for event
handling. It's a really nice idea but I think Panda's version is implemented
weirdly, it uses the subscribe objects as keys in the dictionary. That means
that if you want more than one object to subscribe to the same message you
_have_ to subclass DirectObject and use self.accept(...), can't just call the
messager directly or you'll get a different behaviour, it means that a single
object instance can't subscribe two different functions to the same message, and
it means that your _objects_ have to be _hashable_ (!) because the messager uses
them as keys in a dictionary. It seems to me that it would be much simpler if
the messager's dictionary just mapped message names to function objects, so
that's what I did.

Use this pattern when you have a lot of objects spread throughout the class
hierarchy that need to communicate with each other. It's a way of implementing
one-to-many or many-to-many communication, in which an object can send a message
to many receivers without needing to know who those receivers are, or how many
receivers there are, or even if there are any receivers (although an object can
potentially check all these things if it wants to). The singleton messager
object receives messages from broadcaster objects and forwards them to receiver
objects. Setup a single, simple, generic, system- wide messaging system, instead
of creating different systems for each different type of message or messaging
relation.

The disadvantage of just implementing this pattern once and using it everywhere
is that with lots of senders and receivers it might become difficult to
understand and debug message-based behaviour. Particularly if the order in which
messages are sent and received becomes important, when you send a message with
this pattern there's no way of knowing in what order the receiver objects will
receive the message, and therefore know way of knowing in what order their
responses will be executed, and those responses may include sending more
messages. You can implement some ordering relations by having an object receive
a message, deal with it, then send a different message to other recievers, but I
wouldn't want to overuse that.

Also you have to be careful to avoid clashes in message names.

The GoF Mediator and Observer patterns are similar in that they enable a mode 
of communication between objects in which the sender object broadcasts a 
message without needing to know all of the receiver objects, and the receiver 
objects can receive messages without being tightly coupled to the sender 
object(s).

In the GoF Mediator pattern, the Mediator object is more than just a messager 
that passes messages between other objects and leaves the behaviour up to the 
others. The mediator actually encapsulates the interaction behaviour between 
objects, deciding which methods to call on which objects each time it receives 
a notification from an object. Mediator centralises control of how objects 
cooperate in the mediator class, whereas the Messager pattern leaves this 
control distributed throughout the objects themselves.

In the GoF observer pattern a one-to-many dependency is setup, there is no 
separate Messager object but rather the sender object itself maintains the list 
of reciever object and notifies them of new messages. With its separate 
messager object the Messager pattern enables many-to-many dependencies as well 
as one-to-many.</p> ]]></description>
<pubDate>Wed, 11 Jun 2008 07:03:17 GMT</pubDate>
<guid>http://snipplr.com/view/6650/messager-pattern-from-panda3d/</guid>
</item>
<item>
<title>(Python) Creating list-like objects in Python - chombee</title>
<link>http://snipplr.com/view/6626/creating-listlike-objects-in-python/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Sun, 08 Jun 2008 18:34:00 GMT</pubDate>
<guid>http://snipplr.com/view/6626/creating-listlike-objects-in-python/</guid>
</item>
<item>
<title>(Python) Creating dictionary-like objects in Python using DictMixin - chombee</title>
<link>http://snipplr.com/view/6546/creating-dictionarylike-objects-in-python-using-dictmixin/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Mon, 02 Jun 2008 11:45:35 GMT</pubDate>
<guid>http://snipplr.com/view/6546/creating-dictionarylike-objects-in-python-using-dictmixin/</guid>
</item>
<item>
<title>(Python) get memory usage of current process on unix - fnl</title>
<link>http://snipplr.com/view/6460/get-memory-usage-of-current-process-on-unix/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Mon, 26 May 2008 23:03:02 GMT</pubDate>
<guid>http://snipplr.com/view/6460/get-memory-usage-of-current-process-on-unix/</guid>
</item>
<item>
<title>(Python) YouTube Batch Download Script - abhiomkar</title>
<link>http://snipplr.com/view/6451/youtube-batch-download-script/</link>
<description><![CDATA[ <p>You</p> ]]></description>
<pubDate>Sun, 25 May 2008 14:02:29 GMT</pubDate>
<guid>http://snipplr.com/view/6451/youtube-batch-download-script/</guid>
</item>
</channel>
</rss>