def extract_valid_args(args, func, startidx=0):
 func_args = inspect.getargspec(func).args[startidx:]
 return dict(((k, v) for (k, v) in list(vars(args).items()) if (k in func_args)))

def extract_valid_args ( args , func , startidx = 0 ) : func_args = inspect . getargspec ( func ) . args [ startidx : ] return dict ( ( ( k , v ) for ( k , v ) in list ( vars ( args ) . items ( ) ) if ( k in func_args ) ) )
given a namespace of argparser args .