dummy, underscore and unused local variables

T

Tim Johnson

Consider the following code:
for i in range(mylimit):
foo()
running pychecker gives me a
"""
Local variable (i) not used
"""
complaint.
If I use
for dummy in range(mylimit):
....
## or
for _ in range(mylimit):
....
I get no complaint from pychecker.
I would welcome comments on best practices for this issue.
NOTE: I see much on google regarding unused local variables,
however, doing a search for 'python _' hasn't proved fruitful.

I would like to see comments here specifically on the use for `range'

On a related note: from the python interpreter if I doI get
Help on bool object:

class bool(int)
| bool(x) -> bool
......
I'd welcome comments on this as well.

:) I expect to be edified is so many ways, some
of them unexpected.

thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,189
Members
46,735
Latest member
HikmatRamazanov

Latest Threads

Top