summaryrefslogtreecommitdiffstats
path: root/Python/future.c
diff options
context:
space:
mode:
authorHood Chatham <roberthoodchatham@gmail.com>2024-05-20 17:42:15 (GMT)
committerGitHub <noreply@github.com>2024-05-20 17:42:15 (GMT)
commit7e1a130b8ff1ed8b3a5f00fe0f06d3916b852216 (patch)
tree052d45ada76df8eaec20875c6edfe192c7de9534 /Python/future.c
parent1195c164daab873ebf87ba8efe44fffdf47307ef (diff)
downloadcpython-7e1a130b8ff1ed8b3a5f00fe0f06d3916b852216.zip
cpython-7e1a130b8ff1ed8b3a5f00fe0f06d3916b852216.tar.gz
cpython-7e1a130b8ff1ed8b3a5f00fe0f06d3916b852216.tar.bz2
DOCS: Suggest always calling exec with a globals argument and no locals argument (GH-119235)
Many users think they want a locals argument for various reasons but they do not understand that it makes code be treated as a class definition. They do not want their code treated as a class definition and get surprised. The reason not to pass locals specifically is that the following code raises a `NameError`: ```py exec(""" def f(): print("hi") f() def g(): f() g() """, {}, {}) ``` The reason not to leave out globals is as follows: ```py def t(): exec(""" def f(): print("hi") f() def g(): f() g() """) ```
Diffstat (limited to 'Python/future.c')
0 files changed, 0 insertions, 0 deletions