alias for data member of class instance?

2007-02-05 Thread Sean McIlroy
hi all is there a way to do this ... class clown: def __init__(self): self.x = 0 self.y = ALIAS(self.x) ## FEASIBLE ? ... so that you get results like this ... krusty = clown() krusty.x >> 0 krusty.y >> 0 krusty.x = 1 krusty.x >> 1 krusty.y >> 1 ... ? th

Re: alias for data member of class instance?

2007-02-05 Thread Paul Rubin
"Sean McIlroy" <[EMAIL PROTECTED]> writes: > self.y = ALIAS(self.x) ## FEASIBLE ? The closest thing is probably to use @property. -- http://mail.python.org/mailman/listinfo/python-list

Re: alias for data member of class instance?

2007-02-05 Thread Bruno Desthuilliers
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)

Re: alias for data member of class instance?

2007-02-05 Thread Larry Bates
Sean McIlroy wrote: Sean McIlroy wrote: > hi all > > is there a way to do this ... > > class clown: > def __init__(self): > self.x = 0 > self.y = ALIAS(self.x) ## FEASIBLE ? > > ... so that you get results like this ... > > krusty = clown() > krusty.x >>> 0 > k

Re: alias for data member of class instance?

2007-02-05 Thread Bruno Desthuilliers
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 Alias(object): def __init__(self, attrname): self._attrname = attrname def __get__(s