On 7/14/2010 12:56 AM, Roald de Vries wrote:
I know, I just wondered if there is a *standard* solution.

   Yes, there is.

class floatref(object) :
   def __init__(self, initialval) :
       self.__dict__["_val"] = initialval
   def __getattr__(self, attrname) :
       if attrname == 'val' :
           return(self._val)
       else :
           raise AttributeError(attrname)
   def __setattr__(self, attrname, val) :
       if attrname == 'val' :
           self.__dict__["_val"] = val
       else :
           raise AttributeError(attrname)


x = floatref(1.0)
y = x

print(x.val)
x.val = 10.0
print(x.val)
print(y.val)


Are you happy now?

                                        John Nagle
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to