Is this possible?
Gary
Rainer Mansfeld wrote: <snip>
If OTOH you want your foo class to have sqrt, arccos, etc. methods without defining them explicitly, I think you're looking for something like:
. import Numeric . . class Foo(object): . def __init__(self, value): . self.value = float(value) . for u in ['sqrt', 'cos', 'tan']: . setattr(self, u, lambda uf=getattr(Numeric, u): . uf(self.value + 42.0))
>>> f = Foo(7) >>> f.sqrt() 7.0
HTH Rainer
-- http://mail.python.org/mailman/listinfo/python-list