On 2018-06-21 11:00, INADA Naoki wrote:
When Python 4, I think we can even throw away classmethod and
staticmethod object.
PyFunction can have binding flag instead, like METH_CLASS and
METH_STATIC for PyCFunction.
classmethod and staticmethod is just a function which modify the flag.

One issue with that idea is that staticmethod, classmethod can actually arbitrary objects, not only Python functions. In fact, even this object can be created:

>>> staticmethod(42)
<staticmethod object at 0x7f74ab9c55f8>

So in that sense, they behave more like "method" which can also wrap arbitrary callables (in this case, callability is checked). So I'm vaguely thinking of putting "method", "staticmethod" and "classmethod" on top of a common base class for things wrapping callables.


Jeroen.
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to