Skip to content

Conversation

@andresdelfino
Copy link
Contributor

Text mode works exactly the same as binary mode for updating (w+/r+ vs w+b/r+b):

testfile = 'testfile'

with open(testfile, 'w') as file:
    file.write('A')

with open(testfile, 'r+') as file:
    file_content = file.read()
    print('Content:', file_content)

with open(testfile, 'w+') as file:
    file_content = file.read()
    print('Content:', file_content)

Copy link

@remilapeyre remilapeyre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@DinoV DinoV merged commit c1d8c1c into python:master Sep 10, 2019
@bedevere-bot
Copy link

@DinoV: Please replace # with GH- in the commit message next time. Thanks!

@miss-islington
Copy link
Contributor

Thanks @andresdelfino for the PR, and @DinoV for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 10, 2019
…pythonGH-11314)

* Improve doc on open's mode +

* Improve wording

* Address comment from Rémi
(cherry picked from commit c1d8c1c)

Co-authored-by: Andre Delfino <adelfino@gmail.com>
@bedevere-bot
Copy link

GH-15869 is a backport of this pull request to the 3.8 branch.

gpshead pushed a commit that referenced this pull request Sep 10, 2019
…GH-11314) (GH-15869)

* Improve doc on open's mode +

* Improve wording

* Address comment from Rémi
(cherry picked from commit c1d8c1c)

Co-authored-by: Andre Delfino <adelfino@gmail.com>
websurfer5 pushed a commit to websurfer5/cpython that referenced this pull request Jul 20, 2020
python#11314)

* Improve doc on open's mode +

* Improve wording

* Address comment from Rémi
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 skip issue skip news

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants