Message409090
Maybe a note could be added to https://docs.python.org/3/library/functions.html#exec
Something along the lines of:
Note: If exec gets two separate objects as `globals` and `locals`, the code will not be executed as if it were embedded in a function definition. For example, any function or comprehension defined at the top level will not have access to the `locals` scope.
PS: It would be nice for my usecase to have a way around this, maybe a flag in `compile` or `exec` that would produce "function code" instead of "module code". My workaround for this problem consist in wrapping my code in a function definition.
I think this means https://bugs.python.org/issue41918 should be closed as well? |
|
Date |
User |
Action |
Args |
2021-12-23 14:07:54 | qpeter | set | recipients:
+ qpeter, steven.daprano, eryksun |
2021-12-23 14:07:54 | qpeter | set | messageid: <1640268474.81.0.0668232231038.issue46153@roundup.psfhosted.org> |
2021-12-23 14:07:54 | qpeter | link | issue46153 messages |
2021-12-23 14:07:54 | qpeter | create | |
|