[issue22755] contextlib.closing documentation should use a new example

2021-11-27 Thread Irit Katriel
Change by Irit Katriel : -- versions: +Python 3.10, Python 3.11, Python 3.9 -Python 3.4, Python 3.5, Python 3.6 ___ Python tracker ___

[issue22755] contextlib.closing documentation should use a new example

2014-11-01 Thread Raymond Hettinger
Raymond Hettinger added the comment: Can a different example be chosen? The traditional examples (urllib, socket, StringIO) grow context manager support as soon as the need becomes apparent. So, that leaves only user-defined classes, third-party classes, generators, and cases where we

[issue22755] contextlib.closing documentation should use a new example

2014-10-28 Thread Martijn Pieters
New submission from Martijn Pieters: urllib.request.urlopen() now always produces a context manager (either a HTTPResponse or addinfourl object). The example for contextlib.closing still uses urllib.request.urlopen as an example for the context manager wrapper, see

[issue22755] contextlib.closing documentation should use a new example

2014-10-28 Thread Andrew Barnert
Andrew Barnert added the comment: It may be pretty hard to come up with a good example for closing in the stdlib that shouldn't just be turned into a context manager… There are some types where using it in a with statement is sensible, but unusual enough that you might want to make it

[issue22755] contextlib.closing documentation should use a new example

2014-10-28 Thread Martin Panter
Martin Panter added the comment: One exception that comes to mind is generators. According to Issue 13814, it is deliberate that you have to call close(), so perhaps someone could come up with an example based on that. -- nosy: +vadmium ___ Python