[Python-ideas] Properties for classes possible?
Thomas Güttler
guettliml at thomas-guettler.de
Mon Aug 24 12:07:06 CEST 2015
Am 20.08.2015 um 17:29 schrieb Guido van Rossum:
> I think it's reasonable to propose @classproperty as a patch to CPython. It needs to be C code. Not sure about the
> writable version. The lazy=True part is not appropriate for th he stdlib (it's just a memoize pattern).
What's the next step?
My knowledge of the programming language C is very limited. I am not able to write a
patch for CPython.
I could write a patch which looks like this:
{{{
# From http://stackoverflow.com/a/5192374/633961
class classproperty(object):
def __init__(self, f):
self.f = f
def __get__(self, obj, owner):
return self.f(owner)
}}}
--
Thomas Guettler http://www.thomas-guettler.de/
More information about the Python-ideas
mailing list