Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #197546
| From | Lawrence D’Oliveiro <ldo@nz.invalid> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: can you improve this text-only beginner copy program? (Posting On Python-List Prohibited) |
| Date | 2025-08-28 01:36 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <108obr9$11h9j$1@dont-email.me> (permalink) |
| References | <87a53kdfpx.fsf@somewhere.edu> |
On Wed, 27 Aug 2025 11:03:22 -0300, 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
copy("/proc/sys/kernel/random/uuid", "/dev/full")
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
OSError: [Errno 28] No space left on device
During handling of the above exception, another exception occurred:
OSError Traceback (most recent call last)
Cell In[5], line 11
8 os.remove(d)
9 raise
---> 11 copy("/proc/sys/kernel/random/uuid", "/dev/full")
Cell In[5], line 4, in copy(s, d)
2 """Copies text file named S to text file named D."""
3 with open(s) as src:
----> 4 with open(d, "w") as dst:
5 try:
6 dst.write(src.read())
OSError: [Errno 28] No space left on device
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar
can you improve this text-only beginner copy program? Ethan Carter <ec1828@somewhere.edu> - 2025-08-27 11:03 -0300
Re: can you improve this text-only beginner copy program? ram@zedat.fu-berlin.de (Stefan Ram) - 2025-08-27 15:12 +0000
Re: can you improve this text-only beginner copy program? Ethan Carter <ec1828@somewhere.edu> - 2025-08-27 13:57 -0300
Re: can you improve this text-only beginner copy program? ram@zedat.fu-berlin.de (Stefan Ram) - 2025-08-27 17:45 +0000
Re: can you improve this text-only beginner copy program? Piergiorgio Sartor <piergiorgio.sartor.this.should.not.be.used@nexgo.REMOVETHIS.de> - 2025-08-27 22:21 +0200
Re: can you improve this text-only beginner copy program? Mark Bourne <nntp.mbourne@spamgourmet.com> - 2025-08-28 21:05 +0100
Re: can you improve this text-only beginner copy program? (Posting On Python-List Prohibited) Lawrence D’Oliveiro <ldo@nz.invalid> - 2025-08-28 22:17 +0000
Re: can you improve this text-only beginner copy program? ram@zedat.fu-berlin.de (Stefan Ram) - 2025-08-27 21:09 +0000
Re: can you improve this text-only beginner copy program? Mark Bourne <nntp.mbourne@spamgourmet.com> - 2025-08-28 21:15 +0100
Re: can you improve this text-only beginner copy program? ram@zedat.fu-berlin.de (Stefan Ram) - 2025-08-28 20:50 +0000
Re: can you improve this text-only beginner copy program? (Posting On Python-List Prohibited) Lawrence D’Oliveiro <ldo@nz.invalid> - 2025-08-28 01:36 +0000
csiph-web