def makeStatefulDispatcher(name, template):
 def dispatcher(self, *args, **kwargs):
  func = getattr(self, ((('_' + name) + '_') + self._state), None)
  if (func is None):
   raise RuntimeError(('%r has no %s method in state %s' % (self, name, self._state)))
  return func(*args, **kwargs)
 dispatcher.__doc__ = template.__doc__
 return dispatcher

def makeStatefulDispatcher ( name , template ) : def dispatcher ( self , * args , ** kwargs ) : func = getattr ( self , ( ( ( '_' + name ) + '_' ) + self . _state ) , None ) if ( func is None ) : raise RuntimeError ( ( '%r has no %s method in state %s' % ( self , name , self . _state ) ) ) return func ( * args , ** kwargs ) dispatcher . __doc__ = template . __doc__ return dispatcher
given a i{dispatch} name and a function .