[Python-Dev] PEP 362 minor nits
Yury Selivanov
yselivanov.ml at gmail.com
Wed Jun 20 02:11:26 CEST 2012
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
More information about the Python-Dev
mailing list