Creating a local variable scope.

Ethan Furman ethan at stoneleaf.us
Sat Sep 12 17:02:35 CEST 2009


Daniel Stutzbach wrote:
> On Fri, Sep 11, 2009 at 8:29 PM, Steven D'Aprano 
> <steve at remove-this-cybersource.com.au 
> <mailto:steve at remove-this-cybersource.com.au>> wrote:
> 
>     (4) Create a "do nothing" context manager allowing you to visually
>     indent
>     the block, but otherwise have no effect:
> 
> 
> "with" doesn't create a new scope.

That's probably why he called it as:

with do_nothing() as *imaginary*_local_scope:
     ...
     del spam, eggs, imaginary_local_scope

and then as the last item deleted all the variables, except the one he 
wanted to keep.

~Ethan~



More information about the Python-list mailing list