Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #7523

dummy, underscore and unused local variables

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!selfless.tophat.at!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <tim@johnsons-web.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.017
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; '"""': 0.07; 'interpreter': 0.07; 'python': 0.08; 'bool': 0.09; 'received:64.4': 0.09; 'variables,': 0.09; '>>>': 0.12; 'dummy': 0.16; "'python": 0.19; "hasn't": 0.19; 'issue.': 0.19; 'variable': 0.21; 'expect': 0.25; 'thanks': 0.28; 'class': 0.29; 'google': 0.31; 'specifically': 0.31; 'to:addr:python-list': 0.33; 'however,': 0.34; 'header:User- Agent:1': 0.35; 'charset:us-ascii': 0.36; 'running': 0.37; 'some': 0.38; 'comments': 0.39; 'doing': 0.39; "i'd": 0.39; 'to:addr:python.org': 0.39; 'help': 0.40; 'subject:, ': 0.60; 'best': 0.60; 'note:': 0.63; 'here': 0.66; 'ways,': 0.67; 'subject:local': 0.84
Date Mon, 13 Jun 2011 07:37:02 -0800
From Tim Johnson <tim@johnsons-web.com>
To python-list@python.org
Subject dummy, underscore and unused local variables
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Disposition inline
User-Agent Mutt/1.5.20 (2009-06-14)
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.175.1307979321.11593.python-list@python.org> (permalink)
Lines 39
NNTP-Posting-Host 82.94.164.166
X-Trace 1307979321 news.xs4all.nl 49178 [::ffff:82.94.164.166]:38049
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:7523

Show key headers only | View raw


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 | NextNext in thread | Find similar | Unroll thread


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