from makefun import wraps
def wrap_times_two(f):
@wraps(f)
def wrapper(a):
return f(a) * 2
return wrapper
times_two = wrap_times_two(lambda a: a)
Error in generated code:
def <lambda>(a):
return _func_impl_(a=a)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 3, in wrap_times_two
File "/home/andy/.local/lib/python3.10/site-packages/makefun/main.py", line 954, in replace_f
return create_function(func_signature=func_signature,
File "/home/andy/.local/lib/python3.10/site-packages/makefun/main.py", line 267, in create_function
f = _make(func_name, params_names, body, evaldict)
File "/home/andy/.local/lib/python3.10/site-packages/makefun/main.py", line 629, in _make
code = compile(body, filename, 'single')
File "<makefun-gen-0>", line 1
def <lambda>(a):
^
SyntaxError: invalid syntax
Thanks.
Currently, it's not possible to do
@wraps(f)when f is a lambda function:fails with:
Resolved by #80.
If that's not the right way to go, then it would be helpful to throw an error explaining that lambda functions aren't allowed.
Thanks.