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

Redundant sentence in FAQ #67777

Closed
fossilet mannequin opened this issue Mar 5, 2015 · 9 comments
Closed

Redundant sentence in FAQ #67777

fossilet mannequin opened this issue Mar 5, 2015 · 9 comments
Assignees
Labels
docs Documentation in the Doc dir type-feature A feature request or enhancement

Comments

@fossilet
Copy link
Mannequin

fossilet mannequin commented Mar 5, 2015

BPO 23589
Nosy @rhettinger, @rbtcollins, @ezio-melotti, @bitdancer, @demianbrecht
Files
  • faq_fix.diff
  • faq_fix_1.diff
  • 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 = 'https://github.com/ezio-melotti'
    closed_at = <Date 2015-07-29.18:21:12.664>
    created_at = <Date 2015-03-05.08:32:38.399>
    labels = ['type-feature', 'docs']
    title = 'Redundant sentence in FAQ'
    updated_at = <Date 2015-07-29.18:21:12.664>
    user = 'https://bugs.python.org/fossilet'

    bugs.python.org fields:

    activity = <Date 2015-07-29.18:21:12.664>
    actor = 'rbcollins'
    assignee = 'ezio.melotti'
    closed = True
    closed_date = <Date 2015-07-29.18:21:12.664>
    closer = 'rbcollins'
    components = ['Documentation']
    creation = <Date 2015-03-05.08:32:38.399>
    creator = 'fossilet'
    dependencies = []
    files = ['38339', '38340']
    hgrepos = []
    issue_num = 23589
    keywords = ['patch']
    message_count = 9.0
    messages = ['237248', '237255', '237256', '237261', '237340', '237341', '237365', '247591', '247592']
    nosy_count = 8.0
    nosy_names = ['rhettinger', 'fossilet', 'rbcollins', 'ezio.melotti', 'r.david.murray', 'docs@python', 'python-dev', 'demian.brecht']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue23589'
    versions = ['Python 2.7', 'Python 3.4', 'Python 3.5', 'Python 3.6']

    @fossilet
    Copy link
    Mannequin Author

    fossilet mannequin commented Mar 5, 2015

    In https://docs.python.org/3/faq/programming.html#what-are-the-rules-for-local-and-global-variables-in-python, two sentences of essentially the same meaning exist. I try to remove this redundancy.

    @fossilet fossilet mannequin assigned docspython Mar 5, 2015
    @fossilet fossilet mannequin added docs Documentation in the Doc dir type-feature A feature request or enhancement labels Mar 5, 2015
    @rhettinger
    Copy link
    Contributor

    How about:

    In Python, variables that are only referenced inside a function are implicitly
    global. If a variable is assigned a value anywhere within the function's
    body, it's assumed to be a local unless explicitly declared as global.

    @fossilet
    Copy link
    Mannequin Author

    fossilet mannequin commented Mar 5, 2015

    Updated diff as Raymond's wording.

    @ezio-melotti
    Copy link
    Member

    I think the first sentence could be improved, even though it's correct.
    A superficial reading might give the impression that function variables are implicitly global, or that only the variables inside a function are global, especially if the reader is not familiar with the term "referenced".
    Swapping the two sentences and talking first about assignment might be enough to make clear that the other sentence is talking about variables that are only read/accessed by the function but not defined/assigned.
    The paragraph can also be rephrased to say that Python can freely access variables from outer scopes, but that "global" is required to assign a new value to a global variable, and that variables defined inside a function are local.

    @fossilet
    Copy link
    Mannequin Author

    fossilet mannequin commented Mar 6, 2015

    What about changing the first sentence to:

    In Python, variables that are only referenced but not assigned inside a function are implicitly global.?

    @fossilet
    Copy link
    Mannequin Author

    fossilet mannequin commented Mar 6, 2015

    Or:

    In Python, variables inside a function that are only referenced but not assigned are implicitly global.?

    @demianbrecht
    Copy link
    Mannequin

    demianbrecht mannequin commented Mar 6, 2015

    Not to throw a wrench into this, but would it perhaps not be worthwhile to refactor this section in order to include nonlocals as well (obviously not for 2.7)? It seems a little odd to me to have this amount of detail without mentioning nonlocal.

    @rbtcollins
    Copy link
    Member

    @demian, I agree that there are more improvements we can make. The current patch addresses the specific issue of this bug, and if you wished to make a new issue with further improvements that would be great. I'm going to apply this patch now though.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Jul 29, 2015

    New changeset 02f3bf3f74aa by Robert Collins in branch '2.7':
    Issue bpo-23589: Remove duplicate sentence from the FAQ. Patch by Yongzhi Pan.
    https://hg.python.org/cpython/rev/02f3bf3f74aa

    New changeset 941b9c27b8c8 by Robert Collins in branch '3.4':
    Issue bpo-23589: Remove duplicate sentence from the FAQ. Patch by Yongzhi Pan.
    https://hg.python.org/cpython/rev/941b9c27b8c8

    New changeset 93f3ca8fdc39 by Robert Collins in branch '3.5':
    Issue bpo-23589: Remove duplicate sentence from the FAQ. Patch by Yongzhi Pan.
    https://hg.python.org/cpython/rev/93f3ca8fdc39

    New changeset 7163dd7e9511 by Robert Collins in branch 'default':
    Issue bpo-23589: Remove duplicate sentence from the FAQ. Patch by Yongzhi Pan.
    https://hg.python.org/cpython/rev/7163dd7e9511

    @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
    docs Documentation in the Doc dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants