On 8/27/2025 1:45 PM, Stefan Ram wrote:
Ethan Carter wrote or quoted:
You're right. There's no written statement. The exercise was suggested
by the teacher while in class. It was something like ``write a program
that copies text files by getting source and destination via the
command-line.''
On 2025-08-27, Chris Angelico via Python-list wrote:
> On Thu, 28 Aug 2025 at 01:28, Ethan Carter wrote:
>> def copy(s, d):
>> """Copies text file named S to text file named D."""
>> with open(s) as src:
>> with open(d, "w") as dst:
>> try:
>> dst.write(src.read())
>>
r...@zedat.fu-berlin.de (Stefan Ram) writes:
> Ethan Carter wrote or quoted:
>>Can you think of anything I'm missing?
>
> The correctness of a program as a solution to an assignment
> depends on the exact wording of the assignment, so it's a
> bit difficult to say without seeing it.
You'r
On 27/08/2025 18.57, Ethan Carter wrote:
[...]
"""Copies text file named S to text file named D."""
This is not entirely clear, since case is significant in Python
("S" is not the same as "s"), and it is ambiguous whether it refers
to a file actually named "S" or to a file whose name
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'
On Thu, 28 Aug 2025 at 01:28, Ethan Carter wrote:
> def copy(s, d):
> """Copies text file named S to text file named D."""
> with open(s) as src:
> with open(d, "w") as dst:
> try:
> dst.write(src.read())
> except Exception:
> os.remove(d)
> raise
>
In
The program below only copies text files on purpose---because we haven't
learned about binary files in this course yet. (So I could catch a
UnicodeDecodeError while writing.) If an exception is raised while
writing, I need to delete the file that was created. Can you think of
anything I'm missin