3 ms·
The most frustrating thing that bit me when I was first learning python was the error when you pass the wrong number of arguments to a method: >>> class A(
by stormbrew 13y ago
The most frustrating thing that bit me when I was first learning python was the error when you pass the wrong number of arguments to a method:
>>> class A(object):
... def method(self, a): pass
...
>>> A().method()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: method() takes exactly 2 arguments (1 given)
Once you understand more about how method dispatch works it makes sense, but it's really confusing to be told you were doing something you don't think you are.
- _ZeD_ 13y agopass to python 3 :D >>> class C: ... def m(self,a): ... pass ... >>> C().m() Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: m() missing 1 required positional argument: 'a' >>>
- stormbrew 13y agoNice. I haven't committed this particular error in python 3 yet, so it's good to know they made it more sane.