Skip to main content
deleted 14 characters in body; edited tags
Source Link
poke
  • 391.8k
  • 80
  • 596
  • 632

In Python 2.5.2, the following code raises a TypeErrorTypeError:

>>> class X: ...  def a(self): ...  print "a" ... >>> class Y(X): ...  def a(self): ...  super(Y,self).a() ...  print "b" ... >>> c = Y() >>> c.a() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 3, in a TypeError: super() argument 1 must be type, not classobj 

If I replace the class X with class X(object), it will work. What's the explanation for this?

In Python 2.5.2, the following code raises a TypeError:

>>> class X: ... def a(self): ... print "a" ... >>> class Y(X): ... def a(self): ... super(Y,self).a() ... print "b" ... >>> c = Y() >>> c.a() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 3, in a TypeError: super() argument 1 must be type, not classobj 

If I replace the class X with class X(object), it will work. What's the explanation for this?

In Python 2.5, the following code raises a TypeError:

>>> class X:   def a(self):   print "a" >>> class Y(X):   def a(self):   super(Y,self).a()   print "b" >>> c = Y() >>> c.a() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 3, in a TypeError: super() argument 1 must be type, not classobj 

If I replace the class X with class X(object), it will work. What's the explanation for this?

deleted 20 characters in body
Source Link
tashuhka
  • 5.2k
  • 4
  • 50
  • 67

TheIn Python 2.5.2, the following code raises a TypeError:

>>> class X: ... def a(self): ... print "a" ... >>> class Y(X): ... def a(self): ... super(Y,self).a() ... print "b" ... >>> c = Y() >>> c.a() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 3, in a TypeError: super() argument 1 must be type, not classobj 

If, however I replace class Xthe class X with class X(object)class X(object), the same codeit will work. I am using python 2.5.2. What's the explanation for this?

The following code raises a TypeError:

>>> class X: ... def a(self): ... print "a" ... >>> class Y(X): ... def a(self): ... super(Y,self).a() ... print "b" ... >>> c = Y() >>> c.a() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 3, in a TypeError: super() argument 1 must be type, not classobj 

If, however I replace class X with class X(object), the same code will work. I am using python 2.5.2. What's the explanation for this?

In Python 2.5.2, the following code raises a TypeError:

>>> class X: ... def a(self): ... print "a" ... >>> class Y(X): ... def a(self): ... super(Y,self).a() ... print "b" ... >>> c = Y() >>> c.a() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 3, in a TypeError: super() argument 1 must be type, not classobj 

If I replace the class X with class X(object), it will work. What's the explanation for this?

python Python super() raises TypeError ! Why ?

The following code raises a TypeError  :

 >>>>>> class X: ... def a(self): ... print "a""a" ... >>>>>> class Y(X): ... def a(self): ... super(Y,self).a() ... print "b""b" ... >>>>>> c = Y() >>>>>> c.a() Traceback (most recent call last): File """<stdin>", line 1, in <module> File """<stdin>", line 3, in a TypeError: super() argument 1 must be type, not classobj 

If  , however I replace class X with class X(object)  , the same code will work  . I am using python 2.5.2  .What's What's the explanation for this  ?

python super() raises TypeError ! Why ?

The following code raises a TypeError  :

 >>> class X: ... def a(self): ... print "a" ... >>> class Y(X): ... def a(self): ... super(Y,self).a() ... print "b" ... >>> c = Y() >>> c.a() Traceback (most recent call last): File "", line 1, in File "", line 3, in a TypeError: super() argument 1 must be type, not classobj 

If  , however I replace class X with class X(object)  , the same code will work  . I am using python 2.5.2  .What's the explanation for this  ?

Python super() raises TypeError

The following code raises a TypeError:

>>> class X: ... def a(self): ... print "a" ... >>> class Y(X): ... def a(self): ... super(Y,self).a() ... print "b" ... >>> c = Y() >>> c.a() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 3, in a TypeError: super() argument 1 must be type, not classobj 

If, however I replace class X with class X(object), the same code will work. I am using python 2.5.2. What's the explanation for this?

Source Link
Geo
  • 97.6k
  • 121
  • 356
  • 536
Loading