Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #7523
| Date | 2011-06-13 07:37 -0800 |
|---|---|
| From | Tim Johnson <tim@johnsons-web.com> |
| Subject | dummy, underscore and unused local variables |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.175.1307979321.11593.python-list@python.org> (permalink) |
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 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
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
dummy, underscore and unused local variables Tim Johnson <tim@johnsons-web.com> - 2011-06-13 07:37 -0800
Re: dummy, underscore and unused local variables Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-06-13 16:02 +0000
Re: dummy, underscore and unused local variables Chris Angelico <rosuav@gmail.com> - 2011-06-14 02:28 +1000
Re: dummy, underscore and unused local variables Ben Finney <ben+python@benfinney.id.au> - 2011-06-14 10:39 +1000
csiph-web