def _get_defaults(func):
 code = func.__code__
 pos_count = code.co_argcount
 arg_names = code.co_varnames
 arg_names = arg_names[:pos_count]
 defaults = (func.__defaults__ or ())
 kwdefaults = func.__kwdefaults__
 res = (dict(kwdefaults) if kwdefaults else {})
 pos_offset = (pos_count - len(defaults))
 for (name, value) in zip(arg_names[pos_offset:], defaults):
  assert (name not in res)
  res[name] = value
 return res

def _get_defaults ( func ) : code = func . __code__ pos_count = code . co_argcount arg_names = code . co_varnames arg_names = arg_names [ : pos_count ] defaults = ( func . __defaults__ or ( ) ) kwdefaults = func . __kwdefaults__ res = ( dict ( kwdefaults ) if kwdefaults else { } ) pos_offset = ( pos_count - len ( defaults ) ) for ( name , value ) in zip ( arg_names [ pos_offset : ] , defaults ) : assert ( name not in res ) res [ name ] = value return res
internal helper to extract the default arguments .