-
Notifications
You must be signed in to change notification settings - Fork 17
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
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
almazikv
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request