dummy, underscore and unused local variables

Ben Finney ben+python at benfinney.id.au
Mon Jun 13 20:39:36 EDT 2011


Tim Johnson <tim at johnsons-web.com> writes:

> 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.

I have argued in the past against overloading the name ‘_’ for this
<URL:http://mail.python.org/pipermail/python-list/2008-January/523777.html>
since it has other, unrelated, meanings already established.

Other responses in that thread are also useful.

-- 
 \      “I find the whole business of religion profoundly interesting. |
  `\     But it does mystify me that otherwise intelligent people take |
_o__)                                    it seriously.” —Douglas Adams |
Ben Finney



More information about the Python-list mailing list