> > > class Parrot(object): > > > class count(Property): > > > def Get(prop, self): > > > return self._count > > > def Set(prop, self, value): > > > self._count = value > > > def Del(prop, self): > > > self._count = 0 > > > count = count('Current parrot count') > > > _count = 0 > > > > I'm not sure that this has much to recommend it over the current > > approach. The unused 'prop' argument smells like a remnant of the > > implementation. > > OTOH, if the class were merely used as a container (and never > instantiated), it looks fairly decent (and indeed doesn't need a > [filter] modifier, as MWH already suggested): > > class Parrot(object): > _count = 0 > class count(Property): > """The count property.""" > def __get__(self): > return self._count > def __set__(self, value): > self._count = value > def __del__(self): > self._count = 0 These all abuse the class keyword for something that's definitely not a class. That's a fatal flaw. --Guido van Rossum (home page: http://www.python.org/~guido/)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4