This doesn't have anything in particular to do with file i/o; you can use print()
to print to files just fine:
print("foo bar", end="\n", file=fout)
The .write()
method of file objects just writes stuff to the files, it doesn't write lines. print()
, on the other hand, by default prints a line of output. It needed the end
argument for those cases when you want to print something that's not a whole line; without it, it couldn't fully replace Python 2's print
statement, which includes syntax to omit the default newline.
There's no PEP about not including an end
argument to .write()
, because writing a PEP to keep a method how it already was in the earliest versions of Python wouldn't make any sense...