I don't know how people can trust #python to do maths if it can't even count the number of arguments in a function call.

#rstats

Follow

@eliocamp Interesting! I got a *slightly* more helpful error message:

TypeError: Random.randint() takes 3 positional arguments but 4 were given

Subtly, random.randint calls Random.randint. Presumably it passes along an extra implicit argument (self), but never bothers to count its own arguments.

I'd love to hear a longer explanation from Pythonistas who know more about this.

@peterdrake @eliocamp your assumptions are correct. The called method expects (self, a, b); in the given example it gets (self, a, b, c). Hence the technically correct error message, however misleading it is for the programmer. Happens unfortunately (and reliably) every time you call an instance method with wrong number of arguments.

Sign in to participate in the conversation
CleverLibre Social

CleverLibre Social is an inclusive social instance for open discussion, learning, and community.
All cultures welcome.
Hate speech and harassment strictly forbidden.