Creating properties with decorator like syntax

Will McGugan news at NOwillmcguganSPAM.com
Thu Feb 17 12:10:29 EST 2005


Hi,

Is there any way of making properties using a decorator? The current way 
of creating a property seems inelegant.

Something like this imaginary snippit would be nice, IMHO.

class C(object):
	@make_property
	def x(self):
	    def getx(self): return self.__x
	    def setx(self, value): self.__x = value
	    def delx(self): del self.__x

Regards,

Will McGugan
		



More information about the Python-list mailing list