with statement and standard library

Terry Reedy tjreedy at udel.edu
Fri Feb 19 12:41:10 EST 2010


On 2/19/2010 2:18 AM, nobrowser wrote:
> Hi.  The with statement is certainly nifty.  The trouble is, the
> *only* two documented examples how it can be used with the library
> classes are file objects (which I use all the time) and thread locks
> which I almost never use.  Yet there are many, many classes in the
> library whose use would be more elegant and readable if the with
> statement could be employed.  Start with the connection objects in
> httplib and you can probably come up with 10 others easily.  Maybe it
> is the case that some of these classes have with statement support
> already but I don't know it?  If so, how can I know (without asking
> here each time, LOL)?  If not, is there work being done on that?


> I am interested in this question mostly in the context of Python 2.6.

2.6 is in maintenance mode only; no new features.
2.7 will be so when released in June and effectively so in a month when 
the first beta is released.
3.2 is a reasonable target.

tjr




More information about the Python-list mailing list