I have a object like:
class Foo(object):
def __init__(self,instance):
self.instance = instance
with
>>> instance = SomeOtherObject()
>>> f = Foo(instance)
I want to be able to do
>>> f.some_method()
and have the following call,
>>> f.instance.some_method()
For complicated reasons, I cannot simply chain the attributes as in the above. I need to dynamically create an instance function on f with the same function signature as the embedded instance. That is, I need to do f.some_method() and then dynamically create the some_method instance-method for the f instance when it is invoked that pushes some_method down to the embedded object instance.
I hope that made sense. This is for Python 2.7. Any help appreciated.
Fooin your code, one must pass an instance of something else as an argument, sof = Foo()would cause an error.