Issue 31688: scope error - Python tracker (original) (raw)

Created on 2017-10-04 12:33 by abdullah patel, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
pythonerror.jpg abdullah patel,2017-10-04 12:33 jpg
Messages (4)
msg303682 - (view) Author: abdullah patel (abdullah patel) Date: 2017-10-04 12:33
there should be an error when this code is run. as I have not defined the arguments (I was told by my computer science teacher that it should not work in theory) and parameters but it clearly works.
msg303689 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2017-10-04 13:42
The code looks fine to me; I don't see any reason to expect an error. What error were you expecting, and why?
msg303710 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2017-10-04 16:48
Yes, this conforms to Python's namespace/scoping rules: nested scopes are allowed to reference (but not assign to) variables from the global scope even without a 'global' declaration.
msg303721 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2017-10-04 17:48
Abdullah, in the future, please upload or post runnable Python code, not an image. Output can be copied into a message. If you think IDLE is doing something wrong, test by running the code directly with Python. If your file is test.py, enter the following on a Command Prompt command line. path-to-your-python-code-dir> python -m test.py There would only be an IDLE issue (and then only maybe) if the code ran differently or produced different output in IDLE than with python directly. That is not the case here.
History
Date User Action Args
2022-04-11 14:58:53 admin set github: 75869
2017-10-04 17:48:23 terry.reedy set assignee: terry.reedy -> messages: + components: + Interpreter Core, - IDLE
2017-10-04 16:48:23 r.david.murray set status: open -> closednosy: + r.david.murraymessages: + resolution: not a bugstage: resolved
2017-10-04 13:42:39 mark.dickinson set nosy: + mark.dickinsonmessages: +
2017-10-04 12:33:34 abdullah patel create