for loop without variable

Thomas Heller theller at ctypes.org
Wed Jan 9 18:06:00 EST 2008


erik gartz schrieb:
> Hi. I'd like to be able to write a loop such as:
> for i in range(10):
>     pass
> but without the i variable. The reason for this is I'm using pylint
> and it complains about the unused variable i.

Pychecker won't complain if you rename 'i' to '_', IIRC:

for _ in range(10):
   pass

Thomas




More information about the Python-list mailing list