Tag Archives: Python

Python class advisors

Anyone who has played with Zope 3 has probably seen the syntax used to declare what interfaces a particular class implements. It looks something like this: class Foo: implements(IFoo, IBar) … This leads to the following question: how can a function call inside a class definition’s scope affect the resulting class? To understand how this […]

Version control discussion on the Python list

The Python developers have been discussing a migration off CVS on the python-dev mailing list. During the discussion, Bazaar-NG was mentioned. A few posts of note: Mark Shuttleworth provides some information on the Bazaar roadmap. Importantly, Bazaar-NG will become Bazaar 2.0. Steve Alexander describes how we use Bazaar to develop Launchpad. This includes a description […]

Overriding Class Methods in Python

One of the features added back in Python 2.2 was class methods. These differ from traditional methods in the following ways: They can be called on both the class itself and instances of the class. Rather than binding to an instance, they bind to the class. This means that the first argument passed to the […]

Python Challenge

Found out about The Python Challenge. While you don’t need to use Python to solve most of the problems, a knowledge of the language certainly helps. While the initial problems are fairly easy, some of the later ones are quite difficult, and cover many topics. If you decide to have a go, here are a […]

8 April 2005

Tracing Python Programs I was asked recently whether there was an equivalent of sh -x for Python (ie. print out each statement before it is run), to help with debugging a script. It turns out that there is a module in the Python standard library to do so, but it isn’t listed in the standard […]

Python Unicode Weirdness

While discussing unicode on IRC with owen, we ran into a peculiarity in Python’s unicode handling. It can be tested with the following code: >>> s = u’\U00010001\U00010002′ >>> len(s) >>> s[0] Python can be compiled to use either 16-bit or 32-bit widths for characters in its unicode strings (16-bit being the default). When compiled […]