On Sat, 10 Apr 2010 16:35:29 +0000, Duncan Booth wrote: > Anyway, the moral is never, ever to use old-style classes in Python 2.x. > You will get weird and unexpected results.
That's a bit strong. They're only weird and unexpected if you're not expecting them and don't understand them. Why are we worrying about the exact error message? New style or old style, they both raise TypeError, and testing for the exact error message is a fragile, dangerous thing to do: error strings are not part of the Python API, and are subject to change without notice, for any reason. For all we know, Python runtimes compiled on a Tuesday could use different error messages from runtimes compiled on Wednesdays. I can only think of two circumstances where old-style classes are *wrong*: if you use multiple inheritance with a diamond diagram ("...now you have THREE problems" *wink*), if you intend using descriptors such as properties, or if you need __slots__. That's three circumstances: multiple inheritance with a diamond diagram, descriptors, __slots__, and __getattribute__. Four circumstances. Any other time, they're merely discouraged, and gone in Python 3.x. -- Steven -- http://mail.python.org/mailman/listinfo/python-list