Andrew Dalke
2003-11-05 08:43:00 UTC
Out of curiosity, I tried passing using an invalid base
for a class. I can't explain why I got the error messages
I did. Can someone here enlighten me?
# Here I'm just curious
... return a+b
...
... pass
...
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
TypeError: function() argument 1 must be code, not str
# What's 'function'? Why is it called?
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
TypeError: int() takes at most 2 arguments (3 given)
# what were the three given arguments?
# is it something I can redefine?
... def __getattr__(self, name):
... print "Trying to get", repr(name)
... raise AttributeError(name)
...
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
TypeError: this constructor takes no arguments
# doesn't look like it. What if I derive from an instance
# derived from object?
... def __getattr__(self, name):
... print "Trying to get", repr(name)
... raise AttributeError(name)
...
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
TypeError: default __new__ takes no parameters
# Okay.... Don't know what's going on, so I'll
# just fiddle around a bit.
... def __init__(self): pass
...
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
TypeError: __init__() takes exactly 1 argument (4 given)
... def __init__(self, a): pass
...
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
TypeError: __init__() takes exactly 2 arguments (1 given)
# Which is it; 4 given or 1 given? And
# int had 3 passed to it....
... def __init__(self, **args): print "I have", args
...
I have {}
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
TypeError: __init__() takes exactly 1 argument (4 given)
Comments?
Andrew
***@dalkescientific.com
for a class. I can't explain why I got the error messages
I did. Can someone here enlighten me?
# Here I'm just curious
... return a+b
...
... pass
...
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
TypeError: function() argument 1 must be code, not str
# What's 'function'? Why is it called?
class Spam(1): pass
...Traceback (most recent call last):
File "<interactive input>", line 1, in ?
TypeError: int() takes at most 2 arguments (3 given)
# what were the three given arguments?
# is it something I can redefine?
... def __getattr__(self, name):
... print "Trying to get", repr(name)
... raise AttributeError(name)
...
class Spam(Report()): pass
...Traceback (most recent call last):
File "<interactive input>", line 1, in ?
TypeError: this constructor takes no arguments
# doesn't look like it. What if I derive from an instance
# derived from object?
... def __getattr__(self, name):
... print "Trying to get", repr(name)
... raise AttributeError(name)
...
class Spam(Report()): pass
...Traceback (most recent call last):
File "<interactive input>", line 1, in ?
TypeError: default __new__ takes no parameters
# Okay.... Don't know what's going on, so I'll
# just fiddle around a bit.
... def __init__(self): pass
...
class Spam(ABCD()): pass
...Traceback (most recent call last):
File "<interactive input>", line 1, in ?
TypeError: __init__() takes exactly 1 argument (4 given)
... def __init__(self, a): pass
...
class Spam(ABCD()): pass
...Traceback (most recent call last):
File "<interactive input>", line 1, in ?
TypeError: __init__() takes exactly 2 arguments (1 given)
# Which is it; 4 given or 1 given? And
# int had 3 passed to it....
... def __init__(self, **args): print "I have", args
...
class Spam(XYZZY()): pass
...I have {}
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
TypeError: __init__() takes exactly 1 argument (4 given)
Comments?
Andrew
***@dalkescientific.com