subclassing a module: misleading(?) error message
Thu Jan 4 21:49:22 CET 2007
I ran into a problem I didn't understand at first. I got part of it figured
out. Let me first demonstrate the original problem:
> cat Super.py
self._class = 'Super'
print "%s says 'Hello'" % self._class
> cat Sub.py
self._class = 'Sub'
Python 2.3.4 (#1, Feb 7 2005, 15:50:45)
[GCC 3.3.4 (pre 3.3.5 20040809)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from Super import Super
>>> from Sub import Sub
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "Sub.py", line 4, in ?
TypeError: function takes at most 2 arguments (3 given)
My question is NOT "What's wrong here?"
(The answer to that is that the import in Sub.py should be: from Super
i.e., I tried to use the module itself where I meant to subclass the class
defined in that module).
My questions are:
Why does python complain about a function here? (it's a class definition
Is there really a function being called here?
What function was called?
What two arguments is it expecting?
What three were given?
More information about the Python-list