[Python-Dev] nonlocal keyword in 2.x?

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Thu Oct 22 22:46:21 CEST 2009

On 08:24 pm, martin at v.loewis.de wrote:
>Mike Krell wrote:
>>Is there any possibility of backporting support for the nonlocal 
>>into a  2.x release?
>If so, only into 2.7. Can you please explain why it would be desirable
>to do that? 2.7 will likely be the last 2.x release, so only a fairly
>small portion of the applications would be actually able to use this 
>any other new feature added to 2.7): most code supporting 2.x will also
>have to support 2.6, so the keyword won't be available to such code,

For the same reason that it is desirable to backport all of the other 
changes from 3.x - because it makes the 2.x to 3.x transition easier.

If Python 2.7 supports the nonlocal keyword, then 2.7 becomes that much 
better of a stepping stone towards 3.x.

You've suggested that most 2.x code will have to support 2.6 and so 
won't be able to use the nonlocal keyword even if it is added to 2.7. 
This precise argument could be applied to all of the features in 2.6 
which aim to bring it closer to 3.x.  Any program which must retain 
Python 2.5 compatibility will not be able to use them.  Yet 2.6 is a 
more useful stepping stone towards 3.x than 2.5 is.

So yes, it would be quite desirable to see nonlocal and as many other 
3.x features as possible backported for 2.7.  And depending on how close 
2.7 manages to get, it may make sense to backport anything that doesn't 
make it into 2.7 for a 2.8 release.

The 3.x transition is *hard*.  Anything that makes it easier is good.


More information about the Python-Dev mailing list