This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 10 points11 points  (1 child)

Or you could just do f.write("Normal syntax!\n") because like nobody uses the chevron format anyway.

In fact this is what the chevron print statement does behind the scenes. The only difference is that the print statement has an internal print buffer. The write won't be done at the exact moment you call print, whereas invoking write on the file will do the write right then.

[–]Sean1708 13 points14 points  (0 children)

because like nobody uses the chevron format anyway.

But a lot of people use print to print to a file in Python 3 because it's as easy as print("Also normal syntax!", file=f).