[Python-ideas] Improving this? - foo() takes at least 6 arguments (6 given)
Ethan Furman
ethan at stoneleaf.us
Thu Sep 1 19:19:56 CEST 2011
Steven Klass wrote:
> Hi all,
>
> Most of us who have been coding for awhile have often seen this error and understand the "self" concept. I was helping a junior colleague out and he came to me with this problem.
>
> Colleague: "So my code is apparently asking for 6 arguments and it appears that I gave it 6 arguments"
> Me: "Oh that - Yeah... your short one. It really wants 7.."
>
> That got me thinking and here is the post. Now while this seems simple to fix I know this isn't that simple and a healthy dose of introspection will be required.
How did you get this?
--> class test(object):
... def __init__(self):
... pass
...
--> t = test(1)
2.5
---
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: __init__() takes exactly 1 argument (2 given)
2.7
---
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: __init__() takes exactly 1 argument (2 given)
3.2
---
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: __init__() takes exactly 1 positional argument (2 given)
~Ethan~
More information about the Python-ideas
mailing list