Benjamin Peterson: > I don't really see how this is better/easier than: > class AAA: > def get_x(): pass > def set_x(): pass > x = property(get_x, set_x, None, "The x property")
Perhaps it's better because :) @classmethod def func(self): pass is better than def func(self): pass func = classmethod(func) Christian Heimes: > Python 2.6 and 3.0 already have a new way to modify properties: > > class C(object): > @property > def x(self): return self._x > @x.setter > def x(self, value): self._x = value > @x.deleter > def x(self): del self._x Certainly! It don't intent to replace this way of defining/modifining properties. First, it is an example of "with" statement application. Second, suggested approach allow to write your example in the following way: class C(object): with property as x: def get(self): return self._x def set(self, value): self._x = value def del(self): del self._x IMHO it's quite readable too because of additional identation. _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com