Is using range() in for loops really Pythonic?
Graham Breed
x31equsenet at gmail.com
Sat May 17 01:04:44 EDT 2008
George Sakkis wrote:
> If you push this logic too far, you should del every name immediately
> after the last statement it is used in the scope. I would generally
> find less readable some code spread with del every few lines, micro-
> managing the effective scope of each name. YMMV.
Yes, but ... how about
for i in range(10):
del i
do stuff
?
It makes it clear you aren't using the index and ensures you
get a run-time error if you clobbered an existing variable.
Graham
More information about the Python-list
mailing list