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: 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 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 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