This blog is now hosted at consciou.us

Monday, March 24, 2008

New Classes vs. Old Classes in Python

I found a bit of daftness in Python today:


class A:
def __init__(self):
print "Rutabaga!"

class B(A):
def __init__(self):
super(B, self)

causes:

TypeError: super() argument 1 must be type, not classobj


Changing the first line to:

class A(object):


fixes it.

Now, forgive me if I think that's completely stunted. You could have at least said:

TypeError: to use super(), the superclass must have one of the built-in base classes in its inheritance path.

No comments: