Is using range() in for loops really Pythonic?

Carl Banks pavlovevidence at gmail.com
Mon May 12 19:10:51 EDT 2008


On May 12, 7:03 pm, Ben Finney <bignose+hates-s... at benfinney.id.au>
wrote:
> Carl Banks <pavlovevide... at gmail.com> writes:
> > IMHO, whether a varibale is used or not has got to be one of the least
> > important things of all (in no small part because it's easily
> > discernable from nearby code).
>
> I couldn't disagree more.
>
> If you're binding a name to a value that will never be used, you're
> doing me (the reader of the code) a great favour if you indicate
> clearly and concisely that this value is not intended to be referenced
> anywhere else. Saving time for the reader is a very important job of
> the writer of code.

I don't think knowing in advance whether a variable is going to be
used or not benefits readability.


Carl Banks



More information about the Python-list mailing list