[Python-ideas] built-in argspec for function objects
Oscar Benjamin
oscar.j.benjamin at gmail.com
Sun Jan 27 01:09:15 CET 2013
On 26 January 2013 23:27, nbv4 <nbvfour at gmail.com> wrote:
> def my_function(a, b=c):
> pass
>
>>>> my_function.args
> ['a']
I would have expected 'b' to be in that list.
>>>> my_function.kwargs
> {'b': c}
I would have expected this to be a boolean indicating whether or not
the function accepts **kwargs.
>>>> my_function.all_args
> ['a', 'b']
Rather than args and all_args, I would perhaps have used something
more specific like required_positional_args and positional_args
> What do you all think? Argspec is kind of unwieldy, this I think looks a lot
> nicer.
Are you aware of PEP-362?
http://www.python.org/dev/peps/pep-0362/
I think that inspecting the arguments of a function is a relatively
uncommon thing to do, so I don't really have any problem with the fact
that all the code to do it is located in a special module (inspect).
Oscar
More information about the Python-ideas
mailing list