[Tutor] dummy, underscore and unused local variables

Tim Johnson tim at johnsons-web.com
Sat Jun 11 23:46:29 CEST 2011


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, but I
would like to see comments here specifically on the use for `range'

On a related note: from the python interpreter if I do
>>> help(_) 
I 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
-- 
Tim 
tim at johnsons-web dot com or akwebsoft dot com
http://www.akwebsoft.com


More information about the Tutor mailing list