title: Is it possible to maintain "boundness" of a method when passing it as an object outside its class
body: <p>I'm trying to write a library that will register an arbitrary list of service calls from multiple service endpoints to a container.  I intend to implement the service calls in classes written one per service.  Is there a way to maintain the boundedness of the methods from the service classes when registering them to the container (so they will still have access to the instance data of their owning object instance), or must I register the whole object then write some sort of pass through in the container class with <code>__getattr__</code> or some such to access the methods within instance context?</p>
  
  <p>container:</p>
  
  <pre><code>class ServiceCalls(object):
      def __init__(self):
          self._service_calls = {}
      def register_call(self, name, call):
          if name not in self._service_calls:
              self._service_calls[name] = call
      def __getattr__(self, name):
          if name in self._service_calls:
             return self._service_calls[name]
  </code></pre>
  
  <p>services:</p>
  
  <pre><code>class FooSvc(object):
      def __init__(self, endpoint):
          self.endpoint = endpoint
      def fooize(self, *args, **kwargs):
          #call fooize service call with args/kwargs utilizing self.endpoint
      def fooify(self, *args, **kwargs):
          #call fooify service call with args/kwargs utilizing self.endpoint
  
  
  class BarSvc(object):
      def __init__(self, endpoint):
          self.endpoint = endpoint
      def barize(self, *args, **kwargs):
          #call barize service call with args/kwargs utilizing self.endpoint
      def barify(self, *args, **kwargs):
          #call barify service call with args/kwargs utilizing self.endpoint
  </code></pre>
  
  <p>implementation code:</p>
  
  <pre><code>foosvc = FooSvc('fooendpoint')
  barsvc = BarSvc('barendpoint')
  calls = ServiceCalls()
  calls.register('fooize', foosvc.fooize)
  calls.register('fooify', foosvc.fooify)
  calls.register('barize', barsvc.barize)
  calls.register('barify', barsvc.barify)
  calls.fooize(args)
  </code></pre>