LWN.net Logo

Proposal: Moratorium on Python language changes

Proposal: Moratorium on Python language changes

Posted Oct 23, 2009 15:04 UTC (Fri) by sergey (guest, #31763)
In reply to: Proposal: Moratorium on Python language changes by nevyn
Parent article: Proposal: Moratorium on Python language changes

> I agree conditional expressions are mostly opinion but for 'with' ... can you give some examples?

You can can get in and out of "with" blocks repeatedly with the same context manager instance. Locking and all kinds of transactions are a good example, I'd be surprised if those are not mentioned in a PEP for "with." As for less conventional stuff... I used it once to control output indentation level in a console tool. A primitive bug tracker web application wrapper I wrote for work must use SOAP so suds (https://fedorahosted.org/suds/) is my friend. I'd rather not keep recreating all the SOAP metadata, so I keep the same suds SOAP "factory" inside the wrapper class and use context manager pattern to log into/out of the bug tracker.


(Log in to post comments)

Copyright © 2012, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds