Issue 24003: variable naming - Python tracker (original) (raw)

Issue24003

Created on 2015-04-19 09:43 by kaiser, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
bugs.py kaiser,2015-04-19 09:43
Messages (3)
msg241502 - (view) Author: john kaiser (kaiser) Date: 2015-04-19 09:43
found error when naming variables with basic functions how to replicate while=123 #while should be treated as variable name while True: #this should be treated as a function print while #this should be as a variable name result: File "C:\Users\_you got served_\Desktop\bugs.py", line 1 while = 123 ^ SyntaxError: invalid syntax
msg241505 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2015-04-19 10:10
This is not a bug. "while" is a keyword, it is part of Python's syntax, and you are not permitted to use keywords as variable names. This is not an accident, but a deliberate decision.
msg241549 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2015-04-19 19:21
(... and is documented in The Python 3 and 2 Language Reference manuals: https://docs.python.org/3/reference/lexical_analysis.html#keywords and https://docs.python.org/2/reference/lexical_analysis.html#keywords)
History
Date User Action Args
2022-04-11 14:58:15 admin set github: 68191
2015-04-19 19:21:52 ned.deily set nosy: + ned.deilymessages: +
2015-04-19 18:40:20 zach.ware set stage: resolved
2015-04-19 10:10:19 steven.daprano set status: open -> closednosy: + steven.dapranomessages: + resolution: not a bug
2015-04-19 09:43:09 kaiser create