Re: can you improve this text-only beginner copy program?

Mats Wichmann <[email protected]>
Newsgroups gmane.comp.python.general
Message-ID <[email protected]>
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:
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.