At 09:53 AM 5/3/05 -0700, Guido van Rossum wrote:
>I just came across another use case that is fairly common in the
>standard library: redirecting sys.stdout. This is just a beauty (in
>fact I'll add it to the PEP):
>
>def saving_stdout(f):
Very nice; may I suggest 'redirecting_stdout' as the name instead?
This and other examples from the PEP still have a certain awkwardness of
phrasing in their names. A lot of them seem to cry out for a "with"
prefix, although maybe that's part of the heritage of PEP 310. But Lisp
has functions like 'with-open-file', so I don't think that it's *all* a PEP
310 influence on the examples.
It also seems to me that it would be nice if locks, files, sockets and
similar resources would implement the block-template protocol; then one
could simply say:
block self.__lock:
...
or:
open("foo") as f:
...
And not need any special wrappers. Of course, this could only work for
files if the block-template protocol were distinct from the normal
iteration protocol.
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com