On 8/27/25 08:03, Ethan Carter wrote:
The program below only copies text files on purpose---because we haven't
learned about binary files in this course yet.
So just an observation on this topic (to squirrel away for future
reference): if you never look at contents of the data at all, and it's
just a pure copy, you might as well do that in binary mode - that way
you're sure of an exact copy with no decoding even attempted. There's
not really any "learning" needed, just open it as "rb" for reading and
"wb" for writing.
As another "for future reference" you can combine "with" statement
clauses if the circumstances suit, it means a level less of indentation.
Like:
with open(s) as src, open(d, "w") as dst:
--
https://mail.python.org/mailman3//lists/python-list.python.org