Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #7523 > unrolled thread
| Started by | Tim Johnson <tim@johnsons-web.com> |
|---|---|
| First post | 2011-06-13 07:37 -0800 |
| Last post | 2011-06-14 10:39 +1000 |
| Articles | 4 — 4 participants |
Back to article view | Back to comp.lang.python
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
| From | Tim Johnson <tim@johnsons-web.com> |
|---|---|
| Date | 2011-06-13 07:37 -0800 |
| Subject | dummy, underscore and unused local variables |
| Message-ID | <mailman.175.1307979321.11593.python-list@python.org> |
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
[toc] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2011-06-13 16:02 +0000 |
| Message-ID | <4df6349d$0$30002$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #7523 |
On Mon, 13 Jun 2011 07:37:02 -0800, Tim Johnson wrote: > Consider the following code: [...] You know Tim, if you hadn't blocked my email address in a fit of pique over something that didn't even involve you, you would have seen my answer to your question on the tutor@python.org mailing list yesterday. http://code.activestate.com/lists/python-tutor/83236/ Yes, I realise that Tim probably won't see this either. I'm just making a point. -- Steven
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2011-06-14 02:28 +1000 |
| Message-ID | <mailman.181.1307982531.11593.python-list@python.org> |
| In reply to | #7528 |
On Tue, Jun 14, 2011 at 2:02 AM, Steven D'Aprano <steve+comp.lang.python@pearwood.info> wrote: > On Mon, 13 Jun 2011 07:37:02 -0800, Tim Johnson wrote: > >> Consider the following code: > [...] > > You know Tim, if you hadn't blocked my email address in a fit of pique > over something that didn't even involve you, you would have seen my > answer to your question on the tutor@python.org mailing list yesterday. > > http://code.activestate.com/lists/python-tutor/83236/ > > Yes, I realise that Tim probably won't see this either. I'm just making a > point. > > > > -- > Steven > -- > http://mail.python.org/mailman/listinfo/python-list > As he says, edification comes from a variety of odd sources... I didn't know the linting ignored a variable called 'dummy' or '_'. Worth knowing! ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Ben Finney <ben+python@benfinney.id.au> |
|---|---|
| Date | 2011-06-14 10:39 +1000 |
| Message-ID | <87vcw9tfef.fsf@benfinney.id.au> |
| In reply to | #7523 |
Tim Johnson <tim@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
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web