Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Functions are not properly scoped #6

Closed
codinghipster opened this issue Sep 17, 2021 · 2 comments
Closed

Functions are not properly scoped #6

codinghipster opened this issue Sep 17, 2021 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@codinghipster
Copy link

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
Copy link

same problem

@AlexxIT AlexxIT added the enhancement New feature or request label Jan 20, 2024
@AlexxIT AlexxIT self-assigned this Jan 23, 2024
@AlexxIT
Copy link
Owner

AlexxIT commented Jan 23, 2024

@AlexxIT AlexxIT closed this as completed Jan 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants