Revised PEP 318 - Function/Method Decorator Syntax
Moshe Zadka
m at moshez.org
Tue Jun 10 10:28:45 EDT 2003
On Tue, 10 Jun 2003, Andrew Bennetts <andrew-pythonlist at puzzling.org> wrote:
> class EvilProperty(type):
> def __new__(cls, name, bases, d):
> return property(d.get('get'), d.get('set'), d.get('del'), d['__doc__'])
>
> class C(object):
> class x:
> """An evil test property"""
> __metaclass__ = EvilProperty
> def get(self):
> print 'Getting'
> return 1
> def set(self, value):
> print 'Setting to', value
Wouldn't it be more readable (:)) if you did
class _EvilProperty(type):
....
class EvilProperty:
__metaclass__ = _EvilProperty
class C(object):
class x(EvilProperty):
def get(self):
print 'Getting'
return 1
def set(self, value):
print 'Setting to', value
--
Moshe Zadka -- http://moshez.org/
Buffy: I don't like you hanging out with someone that... short.
Riley: Yeah, a lot of young people nowadays are experimenting with shortness.
Agile Programming Language -- http://www.python.org/
More information about the Python-list
mailing list