pass arguments to FunctionDef as keyword args

This makes it a lot easier to read.
This commit is contained in:
Johnny Robeson 2016-08-29 18:31:43 -04:00
parent ed0adc2b63
commit cda239a06d

View file

@ -114,14 +114,15 @@ def compile_func(arg_names, statements, name='_the_func', debug=False):
bytecode of the compiled function.
"""
func_def = ast.FunctionDef(
name.encode('utf8'),
ast.arguments(
[ast.Name(n, ast.Param()) for n in arg_names],
None, None,
[ex_literal(None) for _ in arg_names],
name=name.encode('utf8'),
args=ast.arguments(
args=[ast.Name(n, ast.Param()) for n in arg_names],
vararg=None,
kwarg=None,
defaults=[ex_literal(None) for _ in arg_names],
),
statements,
[],
body=statements,
decorator_list=[],
)
mod = ast.Module([func_def])
ast.fix_missing_locations(mod)