Re: A way to write properties

2012-01-24 Thread HEK
On Jan 23, 12:45 pm, Arnaud Delobelle wrote: > Hi all, > > It just occurred to me that there's a very simple but slightly > different way to implement properties: > > class PropertyType(type): >     def __get__(self, obj, objtype): >         return self if obj is None else self.get(obj) >     def

A way to write properties

2012-01-23 Thread Arnaud Delobelle
Hi all, It just occurred to me that there's a very simple but slightly different way to implement properties: class PropertyType(type): def __get__(self, obj, objtype): return self if obj is None else self.get(obj) def __set__(self, obj, val): self.set(obj, val) def __