I'm trying to limit a value stored by object (either int or float): class Limited(object): def __init__(self, value, min, max): self.min, self.max = min, max self.n = value def set_n(self,value): if value < self.min: # boundary check self.n = self.min if value > self.max: self.n = self.max else: self.n = value n = property(lambda self : self._value, set_n)
This works, except I would like the class to behave like built-in types, so I can use it like this: a = Limited(7, 0, 10) b = math.sin(a) So that object itself returns it's value (which is stored in a.n). Is this possible? -- http://mail.python.org/mailman/listinfo/python-list