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


Groups > comp.lang.python > #93191

Re: Can anybody explain the '-' in a 2-D creation code?

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 <gary.herron@islandtraining.com>
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 <gary.herron@islandtraining.com>
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 <e90e10c2-6762-4636-9e05-1f96c7c0b2c2@googlegroups.com>
In-Reply-To <e90e10c2-6762-4636-9e05-1f96c7c0b2c2@googlegroups.com>
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 <python-list.python.org>
List-Unsubscribe <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.102.1435302561.3674.python-list@python.org> (permalink)
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

Show key headers only | View raw


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


Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Can anybody explain the '-' in a 2-D creation code? fl <rxjwg98@gmail.com> - 2015-06-25 18:07 -0700
  Re: Can anybody explain the '-' in a 2-D creation code? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-06-26 02:23 +0100
    Re: Can anybody explain the '-' in a 2-D creation code? fl <rxjwg98@gmail.com> - 2015-06-25 18:40 -0700
      Re: Can anybody explain the '-' in a 2-D creation code? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-06-26 03:27 +0100
  Re: Can anybody explain the '-' in a 2-D creation code? André Roberge <andre.roberge@gmail.com> - 2015-06-25 18:24 -0700
  Re: Can anybody explain the '-' in a 2-D creation code? Atnakus Arzah <atnakus.arzah@gmail.com> - 2015-06-25 18:29 -0700
  Re: Can anybody explain the '-' in a 2-D creation code? Gary Herron <gary.herron@islandtraining.com> - 2015-06-25 18:18 -0700

csiph-web