alias for data member of class instance?

Bruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Mon Feb 5 16:41:58 EST 2007


Sean McIlroy a écrit :
> hi all
> 
> is there a way to do this ...
> 
> class clown:
> 	def __init__(self):
> 		self.x = 0
> 		self.y = ALIAS(self.x) ## FEASIBLE ?
> 

class Clown(object):
   def __init__(self):
     self.x = 0

   @apply
   def x():
     def fget(self):
       return self._x
     def fset(self, value):
       self._x = value
     return property(**locals())

   y = x



More information about the Python-list mailing list