This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: del statement documentation doesn't mention name binding behaviour
Type: enhancement Stage:
Components: Documentation Versions:
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, jc13, r.david.murray
Priority: normal Keywords:

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:16adminsetgithub: 68375
2015-05-15 07:32:45jc13setstatus: open -> closed
resolution: not a bug
messages: + msg243253
2015-05-14 11:27:51r.david.murraysetnosy: + r.david.murray
messages: + msg243175
2015-05-14 09:32:48jc13create