Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.027 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'subject:code': 0.07; '*is*': 0.09; 'received:67.192': 0.09; 'received:67.192.241': 0.09; 'received:dfw.emailsrvr.com': 0.09; 'python.': 0.11; 'received:67.192.241.150': 0.16; 'received:smtp150.dfw.emailsrvr.com': 0.16; 'wrote:': 0.16; 'thanks,': 0.19; '>>>': 0.20; 'variable': 0.20; 'received:emailsrvr.com': 0.22; 'header:In-Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; 'tutorial': 0.29; 'received:(smtp server)': 0.31; 'probably': 0.32; 'me?': 0.34; 'subject:?': 0.34; 'could': 0.35; 'to:addr:python-list': 0.35; 'but': 0.36; 'hi,': 0.37; 'subject:: ': 0.37; 'pm,': 0.39; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'subject:-': 0.39; 'subject:the': 0.40; 'skip:u 10': 0.62; 'charset:windows-1252': 0.65; 'about,': 0.84; 'herron': 0.84; 'unclear': 0.84; 'valid,': 0.84 X-Sender-Id: gary.herron@islandtraining.com Date: Thu, 25 Jun 2015 18:18:15 -0700 From: Gary Herron User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Can anybody explain the '-' in a 2-D creation code? References: In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Mailman-Approved-At: Fri, 26 Jun 2015 09:09:20 +0200 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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: 37 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1435302561 news.xs4all.nl 2848 [2001:888:2000:d::a6]:43743 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:93191 On 06/25/2015 06:07 PM, fl wrote: > Hi, > > I read Ned's tutorial on Python. It is very interesting. On its last > example, I cannot understand the '_' in: > > > > board=[[0]*8 for _ in range(8)] > > > I know '_' is the precious answer, but it is still unclear what it is > in the above line. Can you explain it to me? > > > Thanks, He uses _ to indicate a variable whose name and value he does not care about, but it *is* a valid variable name. He could have used ... for i in range ... or ... for unused_variable in range ... This is a valid, though probably unclear, use of that same name: >>> _ = 123 >>> print(_) 123 >>> Gary Herron