Metaprogramming question
Zachary Ware
zachary.ware+pylist at gmail.com
Tue Feb 11 13:25:47 EST 2014
On Tue, Feb 11, 2014 at 12:13 PM, Travis Griggs <travisgriggs at gmail.com> wrote:
> So here’s my basic question. Is there anyway to programatically query that information in python code?
>
> inspect.signature(datetime.datetime.now)
>
> just gives a ValueError. inspect must only be good for the python code that I write, in python. Is there another way to dig out what the interpreter knows there?
Fixing that issue is in the works. Argument Clinic[1][2] has been
added for Python 3.4 which, once all C functions have been converted,
will provide signature information for all builtins (functions written
in C). If you try out the Python 3.4 RC1[3], you can try
inspect.signature(datetime.datetime.now) again and get the information
you expect: that's one of the (unfortunately relatively few) builtins
that is already converted.
Aside from the Argument Clinic effort, builtin functions are pretty
much black boxes to Python--hence why we're trying to fix it!
--
Zach
[1] http://docs.python.org/3.4/howto/clinic.html
[2] http://hg.python.org/cpython/file/default/Tools/clinic/clinic.py
[3] http://python.org/download/releases/3.4.0/
More information about the Python-list
mailing list