Re: [Python-Dev] PEP 362 minor nits

2012年6月19日 17:13:23 -0700

On 2012年06月19日, at 4:17 PM, Jim Jewett wrote:
>> I can tweak the PEP to make it more clear for those who don't know
>> that staticmethods are not exactly methods, but do we really need that?
> 
> I would prefer it, if only because it surprised me. When do
> distinguish between methods, staticmethod isn't usually the odd man
> out.
> 
> And I also agree that the implementation doesn't need to change
> (except to add a comment), only the PEP.
Actually, it appears we don't need those special checks (for classmethod 
and staticmethod) at all.
 class Foo:
 @staticmethod
 def bar(): pass
 >>> Foo.bar
 <function bar ...>
 >>> Foo().bar
 <function bar ...>
 >>> Foo.__dict__['bar']
 <staticmethod ...>
So using the signature will be OK for 'Foo.bar' and 'Foo().bar', but
not for 'Foo.__dict__['bar']' - which I think is fine (since
staticmethod & classmethod instances are not callable)
I'll just remove checks for static- and class-methods from the
PEP signature() algorithm section.
-
Yury
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to