You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It appears that functions (and by extension, lambdas) don't have access to things outside their scope, example:
def foobar():
pass
foobar()
(lambda: foobar())()
Fails with:
2021-09-17 19:05:11 ERROR (SyncWorker_6) [custom_components.python_script] Error executing script: name 'foobar' is not defined
Traceback (most recent call last):
File "/config/custom_components/python_script/__init__.py", line 81, in execute_script
exec(code)
File "/config/python_scripts/example.py", line 7, in <module>
(lambda: foobar())()
File "/config/python_scripts/example.py", line 7, in <lambda>
(lambda: foobar())()
NameError: name 'foobar' is not defined
The text was updated successfully, but these errors were encountered:
It appears that functions (and by extension, lambdas) don't have access to things outside their scope, example:
Fails with:
The text was updated successfully, but these errors were encountered: