[Python-3000] iostack, continued
Josiah Carlson
jcarlson at uci.edu
Wed Jun 7 06:41:03 CEST 2006
"tomer filiba" <tomerfiliba at gmail.com> wrote:
>
> the old thread was getting too nested, so i made a summary
> of the key points raised during that discussion:
>
> http://sebulba.wikispaces.com/project+iostack+todo
>
> is there anything else i missed? any more comments to add
> to the summary?
* """But then there are other streams where you want to call two
*different* .close() methods, and the above would only allow for 1.
Closing multiple times shouldn't be a problem for most streams, but not
closing enough could be a problem."""
* """hrrm... what do you mean by "closing multiple times"? like
socket.shutdown for reading or for writing? but other than sockets, what
else can be closed in multiple ways? you can't close the "reading" of a
file, while keeping it open for writing.
That's not what I meant. What I meant was that most streams don't care
if you close them twice. That is a = file(...);a.close();a.close() is
OK. However, not all streams are robust against *not* closing. From my
perspective, having each of the reading and writing stream classes
include their own .close() method is perfectly reasonable, and if they
happen to refer to the same stream (say a file opened in r+ or w+ mode),
then .close()ing it twice is fine.
But if they refer to different files, sockets, what have you (I'm sure
someone will have a use case for these), and you don't .close() one of
the streams, then that could be a problem.
- Josiah
More information about the Python-3000
mailing list