classification
Title: pathlib.Path.write_text should include a newline argument
Type: enhancement Stage: needs patch
Components: Library (Lib) Versions: Python 3.10
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: THRlWiTi, daniel.ugra, pitrou, uranusjr, xtreak
Priority: normal Keywords: easy

Created on 2015-03-19 09:32 by daniel.ugra, last changed 2020-09-12 08:43 by serhiy.storchaka.

Messages (2)
msg238498 - (view) Author: Ugra Dániel (daniel.ugra) Date: 2015-03-19 09:32
The new pathlib.Path [read|write]_[binary|text] methods will be very useful, one thing I miss badly is the newline argument for write_text.

In some cases text files need a specific line ending (independent from the platform the code is being executed on.) In my mind this is analogous to passing an explicit encoding argument.

Of course, one can always use built-in open for this scenario. It would be a nice addition anyway :)
msg326096 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2018-09-22 16:14
It seems a similar API was suggested in the initial stages at https://bugs.python.org/issue20218#msg209017 . But looking at the reference library in the comment https://github.com/jaraco/path.py I think it's more about converting newlines in the given text with respect to the platform instead of adding one at the end.

Thanks
History
Date User Action Args
2020-09-12 08:43:52serhiy.storchakasetkeywords: + easy
stage: needs patch
versions: + Python 3.10, - Python 3.5
2019-11-20 03:10:10uranusjrsetnosy: + uranusjr
2018-10-05 03:46:09THRlWiTisetnosy: + THRlWiTi
2018-09-22 16:14:12xtreaksetnosy: + xtreak
messages: + msg326096
2015-03-19 20:18:59ned.deilysetnosy: + pitrou
2015-03-19 09:32:41daniel.ugracreate