Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #79720
| From | Marko Rauhamaa <marko@pacujo.net> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Status of side-effecting functions in python |
| Date | 2014-10-26 18:50 +0200 |
| Organization | A noiseless patient Spider |
| Message-ID | <87bnoy93m5.fsf@elektro.pacujo.net> (permalink) |
| References | <c5e3a7e7-5997-47ee-8e81-759f2342c87a@googlegroups.com> <mailman.15174.1414273325.18130.python-list@python.org> <438d510f-05ae-47dd-bcda-42a8b777c99b@googlegroups.com> <m2itm2$l5r$1@dont-email.me> <683c84d8-d916-4b63-b4b2-92cd2763e260@googlegroups.com> |
wxjmfauth@gmail.com:
> Yes and no. If something goes wrong in a .write() method,
> is not Python supposed to raise an error? (!)
We have multiple cases:
1. write succeeds with all of the given bytes
2. write succeeds with some but not all of the given bytes
3. write cannot at the moment write any bytes
4. an I/O error has taken place
Cases 1 and 2 are reported through positive return values in POSIX
system calls. Cases 3 and 4 are reported as errors. Arguably 2 and 3 are
related cases.
Python imitates POSIX, but *could* take a different tack. For example,
* always return with an exception carrying the number of bytes written
* return with None in case 1 and with an exception otherwise
* return with the number of bytes in 1, 2 and 3 and exception in 4
The POSIX way is justified with symmetry: read() distinguishes EAGAIN
from 0 (end of file). One could argue that POSIX got it the wrong way.
EOF should be an exception ("EEOF") and 0 should be used instead of
EAGAIN. However, the POSIX practice works in C and Python.
Marko
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Status of side-effecting functions in python Rustom Mody <rustompmody@gmail.com> - 2014-10-25 10:27 -0700
Re: Status of side-effecting functions in python Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2014-10-25 23:41 +0200
Re: Status of side-effecting functions in python Dan Sommers <dan@tombstonezero.net> - 2014-10-25 22:22 +0000
Re: Status of side-effecting functions in python Terry Reedy <tjreedy@udel.edu> - 2014-10-25 18:53 -0400
Re: Status of side-effecting functions in python wxjmfauth@gmail.com - 2014-10-26 00:45 -0700
Re: Status of side-effecting functions in python Dan Sommers <dan@tombstonezero.net> - 2014-10-26 13:41 +0000
Re: Status of side-effecting functions in python Rustom Mody <rustompmody@gmail.com> - 2014-10-26 07:53 -0700
Re: Status of side-effecting functions in python wxjmfauth@gmail.com - 2014-10-26 09:26 -0700
Re: Status of side-effecting functions in python Marko Rauhamaa <marko@pacujo.net> - 2014-10-26 18:50 +0200
Re: Status of side-effecting functions in python Roy Smith <roy@panix.com> - 2014-10-26 17:56 -0400
Re: Status of side-effecting functions in python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-10-27 22:30 +1100
Re: Status of side-effecting functions in python Chris Angelico <rosuav@gmail.com> - 2014-10-27 22:44 +1100
Re: Status of side-effecting functions in python Roy Smith <roy@panix.com> - 2014-10-27 09:28 -0400
Re: Status of side-effecting functions in python Grant Edwards <invalid@invalid.invalid> - 2014-10-27 14:45 +0000
Re: Status of side-effecting functions in python Marko Rauhamaa <marko@pacujo.net> - 2014-10-27 17:14 +0200
Re: Status of side-effecting functions in python Nobody <nobody@nowhere.invalid> - 2014-10-28 03:52 +0000
Re: Status of side-effecting functions in python Marko Rauhamaa <marko@pacujo.net> - 2014-10-28 11:07 +0200
Re: Status of side-effecting functions in python Marko Rauhamaa <marko@pacujo.net> - 2014-10-28 11:10 +0200
.write() behavior Alan Bawden <alan@scooby-doo.csail.mit.edu> - 2014-10-29 01:06 -0400
Re: .write() behavior Marko Rauhamaa <marko@pacujo.net> - 2014-10-29 08:00 +0200
Re: .write() behavior Alan Bawden <alan@scooby-doo.csail.mit.edu> - 2014-10-31 16:32 -0400
Re: Status of side-effecting functions in python Grant Edwards <invalid@invalid.invalid> - 2014-10-27 14:22 +0000
csiph-web