G
George Sakkis
I came across a strange error when trying to define a settable property
for a new-style subclass of UserArray (Numeric). Here's a shorter
example that reproduces the problem:
from UserArray import UserArray
from math import hypot
class Vector(UserArray,object):
def __init__(self,x,y):
super(Vector,self).__init__((x,y))
def _fget(self): return hypot(*self)
def _fset(self, m): self *= m/self.magnitude
magnitude = property(_fget, _fset)
v = Vector(3.,4.)
print v.magnitude
# the line below prints an infinite sequence of:
# Exception exceptions.AttributeError: "can't delete attribute"
# in ignored
v.magnitude = 10
Any ideas on what's going on and if there's a workaround ?
George
for a new-style subclass of UserArray (Numeric). Here's a shorter
example that reproduces the problem:
from UserArray import UserArray
from math import hypot
class Vector(UserArray,object):
def __init__(self,x,y):
super(Vector,self).__init__((x,y))
def _fget(self): return hypot(*self)
def _fset(self, m): self *= m/self.magnitude
magnitude = property(_fget, _fset)
v = Vector(3.,4.)
print v.magnitude
# the line below prints an infinite sequence of:
# Exception exceptions.AttributeError: "can't delete attribute"
# in ignored
v.magnitude = 10
Any ideas on what's going on and if there's a workaround ?
George