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

Reorder 'with' statement for files in Python Tutorial #50768

Closed
jjalocha mannequin opened this issue Jul 19, 2009 · 10 comments
Closed

Reorder 'with' statement for files in Python Tutorial #50768

jjalocha mannequin opened this issue Jul 19, 2009 · 10 comments
Labels
3.7 (EOL) end of life docs Documentation in the Doc dir type-feature A feature request or enhancement

Comments

@jjalocha
Copy link
Mannequin

jjalocha mannequin commented Jul 19, 2009

BPO 6519
Nosy @akuchling, @birkenfeld, @ezio-melotti, @cjerdonek, @berkerpeksag, @Mariatta
PRs
  • bpo-6519: move discussion of 'with' higher in the discussion of files #2143
  • [3.6] bpo-6519: Improve Python Input Output Tutorial (GH-2143) #2145
  • [3.5] bpo-6519: Improve Python Input Output Tutorial (GH-2143) #2146
  • Files
  • issue6519.txt
  • 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 2017-06-13.05:43:24.027>
    created_at = <Date 2009-07-19.01:19:28.498>
    labels = ['type-feature', '3.7', 'docs']
    title = "Reorder 'with' statement for files in Python Tutorial"
    updated_at = <Date 2017-06-13.05:43:24.025>
    user = 'https://bugs.python.org/jjalocha'

    bugs.python.org fields:

    activity = <Date 2017-06-13.05:43:24.025>
    actor = 'Mariatta'
    assignee = 'docs@python'
    closed = True
    closed_date = <Date 2017-06-13.05:43:24.027>
    closer = 'Mariatta'
    components = ['Documentation']
    creation = <Date 2009-07-19.01:19:28.498>
    creator = 'jjalocha'
    dependencies = []
    files = ['45374']
    hgrepos = []
    issue_num = 6519
    keywords = []
    message_count = 10.0
    messages = ['90698', '100179', '280167', '280208', '295825', '295832', '295847', '295848', '295849', '295850']
    nosy_count = 7.0
    nosy_names = ['akuchling', 'georg.brandl', 'ezio.melotti', 'jjalocha', 'chris.jerdonek', 'berker.peksag', 'Mariatta']
    pr_nums = ['2143', '2145', '2146']
    priority = 'low'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue6519'
    versions = ['Python 3.5', 'Python 3.6', 'Python 3.7']

    @jjalocha
    Copy link
    Mannequin Author

    jjalocha mannequin commented Jul 19, 2009

    Actually, the Python Tutorial recommends the use of the 'with' statement
    in Section 7.2.1. "Methods of File Objects":

    It is good practice to use the with keyword when dealing with file
    objects. [etc.]

    But the example and description are at the very bottom of this very
    large section, and are easily missed by new Python users.

    If this suggestion is to be taken seriously, I suggest putting this
    information at a more prominent place, somewhere at the top of the short
    section 7.2. "Reading and Writing Files".

    @jjalocha jjalocha mannequin assigned birkenfeld Jul 19, 2009
    @jjalocha jjalocha mannequin added docs Documentation in the Doc dir type-feature A feature request or enhancement labels Jul 19, 2009
    @ezio-melotti
    Copy link
    Member

    All the examples there assume that "a file object called f has already been created". Using a 'with' there it's not a good idea because the users will have to keep the instructions indented under the 'with'.
    However I agree that it would be better to move that example earlier. Maybe in 7.2 both the forms can be shown and discussed briefly.

    @admin admin mannequin assigned docspython and unassigned birkenfeld Oct 29, 2010
    @akuchling
    Copy link
    Member

    Good suggestion -- here's a patch that moves it and rewrites a little.

    @berkerpeksag
    Copy link
    Member

    The patch looks good to me. I think we can tweak the content a bit. I left some comments on Rietveld.

    Thanks!

    @berkerpeksag berkerpeksag added the 3.7 (EOL) end of life label Nov 7, 2016
    @Mariatta
    Copy link
    Member

    @akuchling Can you prepare a PR on GitHub?

    @akuchling
    Copy link
    Member

    PR filed against master: #2143

    @Mariatta
    Copy link
    Member

    New changeset bd4e9e0 by Mariatta (Andrew Kuchling) in branch 'master':
    bpo-6519: Improve Python Input Output Tutorial (GH-2143)
    bd4e9e0

    @Mariatta
    Copy link
    Member

    New changeset 81c05cc by Mariatta in branch '3.6':
    bpo-6519: Improve Python Input Output Tutorial (GH-2143) (GH-2145)
    81c05cc

    @Mariatta
    Copy link
    Member

    New changeset 5a86154 by Mariatta in branch '3.5':
    bpo-6519: Improve Python Input Output Tutorial (GH-2143) (GH-2146)
    5a86154

    @Mariatta
    Copy link
    Member

    Thanks everyone!
    I merged the PR and backported to 3.6 and 3.5.

    There are a bunch of conflicts when trying to backport to 2.7, so I decided not to bother.

    @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
    3.7 (EOL) end of life docs Documentation in the Doc dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    5 participants