SilentGhost added the comment:
Those methods were added in 3.5, so no wonder many people would be unaware of
them. I would suggest first taking such a proposal to python-ideas, since bug
tracker is not a venue for proposing/advocating such sweeping changes to the
language.
--
nosy: +S
nickeubank added the comment:
Seems like existence of a method in the stdlib (or at least in the pathlib part
of the stdlib) suggests issues with text encoding can be overcome.
IMHO I would suggest most people have no idea about that method (I've been
doing python for years and this has alway
Serhiy Storchaka added the comment:
Such function already exists in the stdlib! But with different order of
arguments. See pathlib.Path.write_text().
Personally I'm very skeptical about usefulness of similar functions in the
stdlib.
--
nosy: +serhiy.storchaka
STINNER Victor added the comment:
Oh. I wasn't aware of these pathlib methods.
https://docs.python.org/dev/library/pathlib.html#pathlib.Path.write_bytes
https://docs.python.org/dev/library/pathlib.html#pathlib.Path.write_text
--
___
Python tracker
STINNER Victor added the comment:
It's easy to implement such function in a module and upload such module to PyPI
(ex: "to_file" module :-)).
It's not easy to guess user expectations on such function: text encoding,
buffering, etc.
Adding a method to the builtin str type which writes into a f
New submission from nickeubank:
As a social scientists trying to help other social scientists move from
language like R, Stata, and Matlab into Python, one of the behaviors I've found
unnecessarily difficult to explain is the "file.open()/file.close()" idiom (or,
alternatively, context manager