Issue 24187: del statement documentation doesn't mention name binding behaviour (original) (raw)

Issue24187

Created on 2015-05-14 09:32 by jc13, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (3)
msg243163 - (view) Author: Jon (jc13) Date: 2015-05-14 09:32
The documentation for the del keyword in the language reference doesn't mention the name binding behaviour: https://docs.python.org/3/reference/simple_stmts.html#grammar-token-del_stmt It is mentioned in section 4.1 where it says: "A target occurring in a del statement is also considered bound for this purpose" But it's really not obvious to look there when trying to understand what del does. It would be great if this information were added or a reference made to the other section.
msg243175 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2015-05-14 11:27
I don't understand, what do you think is missing from the description? It certainly talks about name binding. Also, can you provide a link to the other statement, as I can't find it, and out of context I have no idea what it is talking about.
msg243253 - (view) Author: Jon (jc13) Date: 2015-05-15 07:32
Sorry, I think I just misread this section. I was confused by the fact that del binds names like assignment does, so that the following tries to delete a local name and fails: x = 1 def f(): del x f() In fact the documentation does say that there must be global statement in the block for del to delete a global name, so my bad.
History
Date User Action Args
2022-04-11 14:58:16 admin set github: 68375
2015-05-15 07:32:45 jc13 set status: open -> closedresolution: not a bugmessages: +
2015-05-14 11:27:51 r.david.murray set nosy: + r.david.murraymessages: +
2015-05-14 09:32:48 jc13 create