Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

variable naming #68191

Closed
kaiser mannequin opened this issue Apr 19, 2015 · 3 comments
Closed

variable naming #68191

kaiser mannequin opened this issue Apr 19, 2015 · 3 comments
Labels
type-bug An unexpected behavior, bug, or error

Comments

@kaiser
Copy link
Mannequin

kaiser mannequin commented Apr 19, 2015

BPO 24003
Nosy @ned-deily, @stevendaprano
Files
  • bugs.py
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2015-04-19.10:10:19.207>
    created_at = <Date 2015-04-19.09:43:09.498>
    labels = ['type-bug', 'invalid']
    title = 'variable naming'
    updated_at = <Date 2015-04-19.19:21:52.304>
    user = 'https://bugs.python.org/kaiser'

    bugs.python.org fields:

    activity = <Date 2015-04-19.19:21:52.304>
    actor = 'ned.deily'
    assignee = 'none'
    closed = True
    closed_date = <Date 2015-04-19.10:10:19.207>
    closer = 'steven.daprano'
    components = []
    creation = <Date 2015-04-19.09:43:09.498>
    creator = 'kaiser'
    dependencies = []
    files = ['39117']
    hgrepos = []
    issue_num = 24003
    keywords = []
    message_count = 3.0
    messages = ['241502', '241505', '241549']
    nosy_count = 3.0
    nosy_names = ['ned.deily', 'steven.daprano', 'kaiser']
    pr_nums = []
    priority = 'normal'
    resolution = 'not a bug'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue24003'
    versions = ['Python 2.7']

    @kaiser
    Copy link
    Mannequin Author

    kaiser mannequin commented Apr 19, 2015

    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

    @kaiser kaiser mannequin added the type-bug An unexpected behavior, bug, or error label Apr 19, 2015
    @stevendaprano
    Copy link
    Member

    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.

    @ned-deily
    Copy link
    Member

    (... 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)

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants