def getrawcode(obj, trycall=True):
 try:
  return obj.__code__
 except AttributeError:
  obj = getattr(obj, u'im_func', obj)
  obj = getattr(obj, u'func_code', obj)
  obj = getattr(obj, u'f_code', obj)
  obj = getattr(obj, u'__code__', obj)
  if (trycall and (not hasattr(obj, u'co_firstlineno'))):
   if (hasattr(obj, u'__call__') and (not inspect.isclass(obj))):
    x = getrawcode(obj.__call__, trycall=False)
    if hasattr(x, u'co_firstlineno'):
     return x
  return obj

def getrawcode ( obj , trycall = True ) : try : return obj . __code__ except AttributeError : obj = getattr ( obj , u'im_func' , obj ) obj = getattr ( obj , u'func_code' , obj ) obj = getattr ( obj , u'f_code' , obj ) obj = getattr ( obj , u'__code__' , obj ) if ( trycall and ( not hasattr ( obj , u'co_firstlineno' ) ) ) : if ( hasattr ( obj , u'__call__' ) and ( not inspect . isclass ( obj ) ) ) : x = getrawcode ( obj . __call__ , trycall = False ) if hasattr ( x , u'co_firstlineno' ) : return x return obj
return code object for given function .