Re: Knowing the signature of a function

2005-06-08 Thread Steven D'Aprano
On Wed, 08 Jun 2005 08:35:39 -0400, Kent Johnson wrote: >> How can I query the function object foo to know the number of parameters >> it expects. I can find it is a function using callable(f), I can find >> some information (listed by dir(foo)) such as the name of the >> function,etc.. but no

Re: Knowing the signature of a function

2005-06-08 Thread =?ISO-8859-1?Q?Xavier_D=E9coret?=
Kent Johnson a écrit : > Xavier Décoret wrote: > >> Hello, >> >> I have the following code: >> >> def foo(x,y): >> pass >> >> How can I query the function object foo to know the number of >> parameters it expects. I can find it is a function using callable(f), >> I can find some information

Re: Knowing the signature of a function

2005-06-08 Thread Kent Johnson
Xavier Décoret wrote: > Hello, > > I have the following code: > > def foo(x,y): > pass > > How can I query the function object foo to know the number of parameters > it expects. I can find it is a function using callable(f), I can find > some information (listed by dir(foo)) such as the n

Re: Knowing the signature of a function

2005-06-08 Thread Gerald Klix
Use the inspect module like: >>> def tf( a, b, c, *arguments, **keywordArguments ): ... print "tf" ... >>> import inspect >>> inspect.getargspec( tf ) (['a', 'b', 'c'], 'arguments', 'keywordArguments', None) >>> Xavier Décoret schrieb: > Hello, > > I have the following code: > > def foo(x,