def get_function_argspec(func):
 if (not callable(func)):
  raise TypeError('{0} is not a callable'.format(func))
 if six.PY2:
  if inspect.isfunction(func):
   aspec = inspect.getargspec(func)
  elif inspect.ismethod(func):
   aspec = inspect.getargspec(func)
   del aspec.args[0]
  elif isinstance(func, object):
   aspec = inspect.getargspec(func.__call__)
   del aspec.args[0]
  else:
   raise TypeError("Cannot inspect argument list for '{0}'".format(func))
 elif inspect.isfunction(func):
  aspec = _getargspec(func)
 elif inspect.ismethod(func):
  aspec = _getargspec(func)
  del aspec.args[0]
 elif isinstance(func, object):
  aspec = _getargspec(func.__call__)
  del aspec.args[0]
 else:
  raise TypeError("Cannot inspect argument list for '{0}'".format(func))
 return aspec

def get_function_argspec ( func ) : if ( not callable ( func ) ) : raise TypeError ( '{0} is not a callable' . format ( func ) ) if six . PY2 : if inspect . isfunction ( func ) : aspec = inspect . getargspec ( func ) elif inspect . ismethod ( func ) : aspec = inspect . getargspec ( func ) del aspec . args [ 0 ] elif isinstance ( func , object ) : aspec = inspect . getargspec ( func . __call__ ) del aspec . args [ 0 ] else : raise TypeError ( "Cannot inspect argument list for '{0}'" . format ( func ) ) elif inspect . isfunction ( func ) : aspec = _getargspec ( func ) elif inspect . ismethod ( func ) : aspec = _getargspec ( func ) del aspec . args [ 0 ] elif isinstance ( func , object ) : aspec = _getargspec ( func . __call__ ) del aspec . args [ 0 ] else : raise TypeError ( "Cannot inspect argument list for '{0}'" . format ( func ) ) return aspec
a small wrapper around getargspec that also supports callable classes .