I'd like for an attribute call like object.x to return the results of some method, say object.other.other_method(). How can I do this?
Edit: I asked a bit soon: it looks like I can do this with
object.__dict__['x']=object.other.other_method()
Is this an OK way to do this?
object.other.other_method()inobject.x, which means that the method will only be called once, not each timeobject.xis read. If you want the method to be called every time, @muksie has it right — check out thepropertydecorator. - Ben Blank