Title: Update 'how do I set a global variable' faq entry
Type: enhancement Stage: resolved
Components: Documentation Versions: Python 3.1, Python 3.2, Python 2.7, Python 2.6
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: georg.brandl, olau, r.david.murray
Priority: normal Keywords: patch

Created on 2009-11-09 03:53 by r.david.murray, last changed 2009-11-10 19:00 by r.david.murray. This issue is now closed.

File name Uploaded Description Edit
UnboundLocalError-faq.patch r.david.murray, 2009-11-09 03:53
UnboundLocalError-faq.rst r.david.murray, 2009-11-09 03:53
Messages (3)
msg95057 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-11-09 03:53
Someone else closed issue 7276, but I was thinking of doing so but
wanted to include a pointer to the relevant documentation.  I'm not sure
where that documentation is, but I figured there ought to be a FAQ entry
for it.  And there is, sort of...the first two sections of the
programming faq's 'core language' section.  However, I think that the
way that most people run in to this problem is by getting the
'UnboundLocalError', and so I think the FAQ entry title should mention
that error.  I attach a proposed update to the first section of the core
language section of the programming FAQ.  I'm also going to attach a
copy of the complete entry since it is hard to read in the patch.
msg95106 - (view) Author: Ole Laursen (olau) Date: 2009-11-10 11:28
As the reporter of issue 7276, I think it's a clear explanation of this 
phenomonen. I think that maybe you should remove the "New Python 
programmers" in

"New Python programmers are often surprised when they get this error in 
previously working code when they modify it by adding an assignment 
statement somewhere in the body of a function."

so say something like

"It can be a surprise to get this error in previously working code when it 
is modified by adding an assignment statement somewhere in a function 
msg95128 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-11-10 19:00
Committed, with your suggested rewording, in r76190.
Date User Action Args
2009-11-10 19:00:32r.david.murraysetstatus: open -> closed
resolution: accepted
messages: + msg95128

stage: patch review -> resolved
2009-11-10 11:28:47olausetnosy: + olau
messages: + msg95106
2009-11-09 03:53:51r.david.murraysetfiles: + UnboundLocalError-faq.rst
2009-11-09 03:53:14r.david.murraycreate