The reason is that super()
only operates on new-style classes, which in the 2.x series means extending from object
:
>>> class X(object):
def a(self):
print 'a'
>>> class Y(X):
def a(self):
super(Y, self).a()
print 'b'
>>> c = Y()
>>> c.a()
a
b
More Related Contents:
- Understanding Python super() with __init__() methods [duplicate]
- What does ‘super’ do in Python? – difference between super().__init__() and explicit superclass __init__()
- Calling parent class __init__ with multiple inheritance, what’s the right way?
- super() fails with error: TypeError “argument 1 must be type, not classobj” when parent does not inherit from object
- Is super() broken in Python-2.x? [closed]
- Python super() arguments: why not super(obj)?
- How does Python 2 compare string and int? Why do lists compare as greater than numbers, and tuples greater than lists?
- What is the best way to remove accents (normalize) in a Python unicode string?
- What are the differences between type() and isinstance()?
- Nested arguments not compiling
- Alternative to dict comprehension prior to Python 2.7
- What is __future__ in Python used for and how/when to use it, and how it works
- Converting “yield from” statement to Python 2.7 code
- Using print() (the function version) in Python2.x
- What is the difference between encode/decode?
- Defining “boolness” of a class in python
- How to print a percentage value in python?
- Safest way to convert float to integer in python?
- How does Python’s “super” do the right thing?
- When calling super() in a derived class, can I pass in self.__class__? [duplicate]
- How to call a property of the base class if this property is being overwritten in the derived class?
- Simple python inheritance
- Python ascii utf unicode
- How to select a directory and store the location using tkinter in Python
- Command-line input causes SyntaxError
- TypeError: super() takes at least 1 argument (0 given) error is specific to any python version?
- Is it possible to do partial inheritance with Python?
- What arguments does Python sort() function have?
- Which of the 4 ways to call super() in Python 3 to use?
- Inheriting methods’ docstrings in Python