def getinfo(func):
 assert (inspect.ismethod(func) or inspect.isfunction(func))
 if (sys.version_info[0] >= 3):
  argspec = inspect.getfullargspec(func)
 else:
  argspec = inspect.getargspec(func)
 (regargs, varargs, varkwargs, defaults) = argspec[:4]
 argnames = list(regargs)
 if varargs:
  argnames.append(varargs)
 if varkwargs:
  argnames.append(varkwargs)
 signature = inspect.formatargspec(regargs, varargs, varkwargs, defaults, formatvalue=(lambda value: ''))[1:(-1)]
 if hasattr(func, '__closure__'):
  _closure = func.__closure__
  _globals = func.__globals__
 else:
  _closure = func.func_closure
  _globals = func.func_globals
 return dict(name=func.__name__, argnames=argnames, signature=signature, defaults=func.__defaults__, doc=func.__doc__, module=func.__module__, dict=func.__dict__, globals=_globals, closure=_closure)

def getinfo ( func ) : assert ( inspect . ismethod ( func ) or inspect . isfunction ( func ) ) if ( sys . version_info [ 0 ] >= 3 ) : argspec = inspect . getfullargspec ( func ) else : argspec = inspect . getargspec ( func ) ( regargs , varargs , varkwargs , defaults ) = argspec [ : 4 ] argnames = list ( regargs ) if varargs : argnames . append ( varargs ) if varkwargs : argnames . append ( varkwargs ) signature = inspect . formatargspec ( regargs , varargs , varkwargs , defaults , formatvalue = ( lambda value : '' ) ) [ 1 : ( - 1 ) ] if hasattr ( func , '__closure__' ) : _closure = func . __closure__ _globals = func . __globals__ else : _closure = func . func_closure _globals = func . func_globals return dict ( name = func . __name__ , argnames = argnames , signature = signature , defaults = func . __defaults__ , doc = func . __doc__ , module = func . __module__ , dict = func . __dict__ , globals = _globals , closure = _closure )
returns an info dictionary containing: - name - argnames - defaults - signature - doc - module - dict .