[Python-Dev] 'With' context documentation draft (was Re: Terminology for PEP 343

Terry Reedy tjreedy at udel.edu
Fri Jul 8 19:58:27 CEST 2005


"Walter Dörwald" <walter at livinglogic.de> wrote in message 
news:42CE6600.6070700 at livinglogic.de...
>x = blist()
>x(1)
>with blist(x) as x:
>    x(2)
>    with blist(x) as x:
>       x(3)
>    x(4)
>x(5)

>This would create the list:
>[1, [2, [3], 4], 5]

>With the current version of PEP 343, we would either have to use
>different variable names on each level

To me, different  names on each level -- x0, x1, x2, ... would be clearer 
and preferable, so I would know right off which level something was being 
put at.

This is no different from using differnt iteration variables -- i,j,k; or 
i1, i2, i3; etc -- with nested loops.  In both cases, you can delete the 
unneeded var if you really care and will not be using them again for 
another nested construct.

Terry J. Reedy





More information about the Python-Dev mailing list