[pypy-dev] Allow subclassing `staticmethod` and `classmethod`

cool-RR cool-rr at cool-rr.com
Tue May 3 13:25:40 CEST 2011


In my project I made an `abstract_static_method` class:

https://github.com/cool-RR/GarlicSim/blob/master/garlicsim/garlicsim/general_misc/abc_tools.py#L7

<https://github.com/cool-RR/GarlicSim/blob/master/garlicsim/garlicsim/general_misc/abc_tools.py#L7>A
similar one has been made in Python 3.2:

http://hg.python.org/cpython/file/default/Lib/abc.py#l48


<http://hg.python.org/cpython/file/default/Lib/abc.py#l48>In Pypy this
currently cannot be done, because if you subclass `staticmethod` into
`abstractstaticmethod`, any instances will have a class of `staticmethod`
instead of `abstractstaticmethod`:

>>>> class A(staticmethod):
....   pass
....
>>>> def f():
....   pass
....
>>>> a = A(f)
>>>> a
<staticmethod object at 0x00f2ade0>
>>>> type(a)
<type 'staticmethod'>


What can be done? I want to have `abstract_static_method` in my code.


Thanks,
Ram.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20110503/9f528de0/attachment.html>


More information about the pypy-dev mailing list