and sets both the global and the local namespace to namespace.
I later also realized that only the local namespace should be set to namespace and the global one to globals() like you finally did using
exec(s, globals(), namespace)
In this case, only globals() will contain '__builtins__' and there should be no need to try removing it from namespace.
I've added a warning in the case where no function is found (e.g. when one uses a lambda function and forgets to assign it to a name).
Coverage decreased (-0.008%) to 90.713% when pulling a4c05c6cab17d94fdf8323c8202dafbd08a2cd4b on peterstangl:wc_function_factory into de025392266a92e436247d997f3c84600e20505d on flav-io:master.
@DavidMStraub In my comment https://github.com/flav-io/flavio/pull/52#issuecomment-411542206, I wrote that the
namespace
dictionary would contain a'__builtins__'
key. However, this is only true if one useswhich is equivalent to
and sets both the global and the local namespace to
namespace
. I later also realized that only the local namespace should be set tonamespace
and the global one toglobals()
like you finally did usingIn this case, only
globals()
will contain'__builtins__'
and there should be no need to try removing it fromnamespace
.I've added a warning in the case where no function is found (e.g. when one uses a lambda function and forgets to assign it to a name).
I also changed
hasattr(f, '__call__')
tocallable(f)
(see e.g. the discussion here: https://stackoverflow.com/questions/16388059/using-callablex-vs-hasattrx-call)By the way, great idea to use an OrderedDict and use the last variable as the
fit_wc_function
!