[Python-Dev] signature object issues (to discuss while I am out of contact)
Nick Coghlan
ncoghlan at gmail.com
Wed May 3 12:15:54 CEST 2006
Brett Cannon wrote:
> On 5/2/06, Nick Coghlan <ncoghlan at gmail.com> wrote:
>> All of the use cases I can think of (introspection for documentation
>> purposes
>> or argument checking purposes) don't really suffer either way
>> regardless of
>> whether the signature retrieval is spelt "obj.__signature__" or
>> "inspect.getsignature(obj)".
>>
>
> It does for decorators. How do you make sure that a decorator uses
> the signature object of the wrapped function instead of the decorator?
> Or are you saying to just not worry about that right now?
Ah, good point. In that case, I'd be in favour of including the attribute in
the PEP, and having inspect.getsignature() check for that attribute before
manually building a signature object from the function and its code object.
The other nice thing about the attribute is that it allows otherwise
uninspectable functions (like C functions) to choose to declare their API for
introspection purposes.
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
---------------------------------------------------------------
http://www.boredomandlaziness.org
More information about the Python-Dev
mailing list