George Sakkis wrote: > Another case I've found handy to use lambdas and expressions instead of > named functions and statements is for simple properties: > > class SomeArray(object): > dimensions = property( > fget = lambda self: (self.x,self.y), > fset = lambda self,(x,y): setattr(self,'x',x) or > setattr(self,'y',y))
How about: class SomeArray(object): @apply def dimensions(): def fget(self): return (self.x, self.y) def fset(self, (x, y)): self.x = x self.y = y return property(fget, fset) It doesn't have the "one-liner" appeal of the lambda version, but it reads well. -- Benji York -- http://mail.python.org/mailman/listinfo/python-list