-
-
Notifications
You must be signed in to change notification settings - Fork 30.2k
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
del and name binding #125677
Comments
Link: https://docs.python.org/3/reference/executionmodel.html#binding-of-names The point made by this paragraph is relevant because |
I am not sure what you comment means (but I am also not sure what the current doc means either...).
|
If there is an occurrence of In other words, these two programs behave differently: a = "global"
def outer():
def inner():
print(a)
if False:
del a
inner()
outer() a = "global"
def outer():
def inner():
print(a)
inner()
outer() |
OK, I can see this now. It is confusing because it is about a name already being bound, but the discussion is about how names become bound. Is |
|
Thanks, the explanation makes sense. I don't see a better way to word the current text to capture this, so I'll close this issue. |
Documentation
Section 4.2.1 in Execution model says "A target occurring in a
del
statement is also considered bound for this purpose (though the actual semantics are to unbind the name)." The "for this purpose" makes no sense because the target of adel
statement must already be bound to something; otherwise you get aNameError
.I propose that this paragraph either be removed or worded better to say why the target that is already bound is rebound (if that's what it is trying to say).
The text was updated successfully, but these errors were encountered: