[Python-Dev] PEP 362: 4th edition

Yury Selivanov yselivanov.ml at gmail.com
Tue Jun 19 03:57:38 CEST 2012


On 2012-06-18, at 9:50 PM, Steven D'Aprano wrote:

> On Mon, Jun 18, 2012 at 07:10:33PM -0400, Yury Selivanov wrote:
> 
>> It seems that we have the following options for 'signature(obj)':
>> 
>> 1. If 'obj' has a '__signature__' attribute - return a copy of it,
>> if not - create a new one.
>> 
>> 2. If 'obj' has a '__signature__' attribute - return it,
>> if not - create a new one.
>> 
>> 3. Same as '2', but Signature is also immutable.
> 
> There's a slight ambiguity there. Do you mean, create a __signature__ 
> attribute, or just create a new Signature instance?
> 
> I presume you mean the later, a Signature instance, and not cache it in 
> __signature__.


Right. No implicit caching to __signature__ by the signature() function.

So, more verbose:

1. If 'obj' has a '__signature__' attribute - return a copy of its value, 
if not - create a new Signature and return it.

2. If 'obj' has a '__signature__' attribute - return a copy of its value, 
if not - create a new Signature and return it.

3. Same as '2', but Signature is also immutable.

Thanks!
-
Yury


More information about the Python-Dev mailing list