Re: Incorrect number of arguments

2005-06-09 Thread Andrew Dalke
Steven D'Aprano wrote: > *eureka moment* > > I can use introspection on the function directly to see > how many arguments it accepts, instead of actually > calling the function and trapping the exception. For funsies, the function 'can_call' below takes a function 'f' and returns a new function

Re: Incorrect number of arguments

2005-06-08 Thread Steven D'Aprano
Steven D'Aprano wrote: > I worked around this problem by predicting what error message to expect > given N expected arguments and M supplied arguments. Yuck: this is a > messy, inelegant, ugly hack :-( Thank goodness that functions are first > class objects that support introspection :-) *eure

Incorrect number of arguments

2005-06-08 Thread Steven D'Aprano
I'm trying to keep an open mind, but I am perplexed about something in Python that strikes me as a poor design. py> def func(a,b): py> print a,b py> func(1) Traceback (most recent call last): File "", line 1, in ? TypeError: func() takes exactly 2 arguments (1 given) Why is the exception