def build_arg_list(fn, env):
 kw = {}
 argspec = inspect.getargspec(fn)
 if argspec[2]:
  kw = env
 else:
  argnames = argspec[0][1:]
  for name in argnames:
   if (name in env):
    kw[name] = env[name]
 return kw

def build_arg_list ( fn , env ) : kw = { } argspec = inspect . getargspec ( fn ) if argspec [ 2 ] : kw = env else : argnames = argspec [ 0 ] [ 1 : ] for name in argnames : if ( name in env ) : kw [ name ] = env [ name ] return kw
given a fn and and environment the builds a keyword argument list for fn .