def _make_bound_method(func, self):
 class Foo(object, ):
  def meth(self):
   pass
 f = Foo()
 bound_method = type(f.meth)
 try:
  return bound_method(func, self, self.__class__)
 except TypeError:
  return bound_method(func, self)

def _make_bound_method ( func , self ) : class Foo ( object , ) : def meth ( self ) : pass f = Foo ( ) bound_method = type ( f . meth ) try : return bound_method ( func , self , self . __class__ ) except TypeError : return bound_method ( func , self )
magic for creating bound methods .