[IronPython] Function Signatures - inspect.getargspec
Michael Foord
fuzzyman at voidspace.org.uk
Mon Dec 25 20:29:33 CET 2006
Anthony Baxter wrote:
> On 12/25/06, Michael Foord <fuzzyman at voidspace.org.uk> wrote:
>> Hello all,
>>
>> I'm trying to determine function signatures from IronPython.
>>
>> In Python I'd use 'inspect.getargspec'.
>>
>> In IronPython this raises a 'NotImplementedError'.
>
> 'inspect' is a pure-python module. Where's the NotImplementedError from?
>
I thought it was, but when I checked the standard library I failed to
see it. Oops.
> Hm. A bit of poking around.
>
> def foo(a,b,*c): pass
>
> foo.func_code.co_code is unimplemented - inspect does some foul
> disassembly of this for anonymous tuple arguments. I doubt that's ever
> going to work, but otherwise it's OK. Except for the bugs.
>
Disassembly - yuck ! So that can never work for IronPython.
> In CPython:
>>>> def foo(a,b,*c):
> ... pass
> ...
>>>> foo.func_code.co_argcount
> 2
>
> While in IronPython...
>>>> def foo(a,b,*c):
> ... pass
> ...
>>>> foo.func_code.co_argcount
> 3
So if this worked and I had all the named arguments I could tell *if*
there were some anonymous tuple arguments (varargs or varkwargs), even
know their names but not tell the difference between them.
It would be great if IronPython could provide an alternative interface
for deducing this information. Some platform specific code could then be
put in 'inspect.py'.
Michael Foord
http://www.voidspace.org.uk/python/articles.shtml
> _______________________________________________
> users mailing list
> users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.409 / Virus Database: 268.15.26/601 - Release Date: 24/12/2006
More information about the Ironpython-users
mailing list