Creating a local variable scope.

Johan Grönqvist johan.gronqvist at gmail.com
Fri Sep 18 09:55:47 EDT 2009


Thanks for all replies.

First, two general comments, and then my conclusions:

I did not intend to ask for new features, but my interest was in writing 
readable code that works in python 2.5, although I may upgrade to 2.6 soon.

Also, what I gave was intended as a minimal example, and not a complete 
use case.


Summarizing the answers, it seems that I will try to follow three 
suggestions:

1) In general, try to restructure the code into smaller modules and 
smaller functions.

2) When using many local variables bindings to create one larger object, 
define an inner function that hides those bindings.

3) If I define a few values intended to be used very locally, delete 
those after use.

Thanks again,

Johan




More information about the Python-list mailing list