LWN.net Logo

Advertisement

Front, Kernel, Security, Distributions, Development. See your byline here on LWN.net.

Advertise here

Proposal: Moratorium on Python language changes

Proposal: Moratorium on Python language changes

Posted Oct 22, 2009 19:04 UTC (Thu) by nevyn (subscriber, #33129)
In reply to: Proposal: Moratorium on Python language changes by sergey
Parent article: Proposal: Moratorium on Python language changes

I use with and conditional expressions all the time and write context managers very often. It makes my life easier that open/close semantics is part of the language. I don't even have to document how to grab a resource and give it back when done -- it's obvious.

I agree conditional expressions are mostly opinion but for 'with' ... can you give some examples? I guess my biggest confusion is why you need it over just using __del__ and reference counting? (what I do with files). It also seems weird because now you can't easily change code to move things out of blocks, because the end of the block explicitly closes one or more resources (generally what I need to do with dbconnections).

All these arguments above are actually in favor of keeping the language fluid: there doesn't seem to be a single case where new features harm anybody.

I agree, I think with the move to py3k breaking so much old code and generally causing lots of pain ... people have probably voiced that they want more stability, but I don't think it's the new features which were the problem (Eg. I moved to 2.6.x almost immediately, I'm still dreading moving to py3k).

I think RHEL or any other distribution's choice is much less relevant than it seems.

I guess it depends on who you are, and it's possible be that a "lot" of large companies will move to internal versions of py3k before RHEL-6 is dead ... but my code gets deployed on other people's RHEL-x so I have no choice, and I know of a lot of people who own their production servers who would have to have a very big reason to maintain their own version of a big critical like python.


(Log in to post comments)

Proposal: Moratorium on Python language changes

Posted Oct 22, 2009 20:46 UTC (Thu) by tan2 (subscriber, #42953) [Link]

I agree conditional expressions are mostly opinion but for 'with' ... can you give some examples? I guess my biggest confusion is why you need it over just using __del__ and reference counting? (what I do with files).

Because it's hard to control who holds the reference. See this post on comp.lang.python for an example.

Proposal: Moratorium on Python language changes

Posted Oct 23, 2009 15:04 UTC (Fri) by sergey (guest, #31763) [Link]

> 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.

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