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


Groups > comp.lang.python > #47624

Re: "Don't rebind built-in names*" - it confuses readers

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python.list@tim.thechases.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.011
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'syntax': 0.04; 'compiler': 0.07; 'permitted': 0.07; 'prevents': 0.09; 'subtle': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; '-tkc': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'janssen': 0.16; 'keyword.': 0.16; 'sees': 0.16; 'syntaxerror:': 0.16; 'wrote:': 0.18; 'variable': 0.18; '>>>': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'cc:2**1': 0.23; "shouldn't": 0.24; 'cc:no real name:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'generally': 0.29; '"",': 0.31; 'allows': 0.31; 'file': 0.32; 'style': 0.33; 'actual': 0.34; 'advice': 0.35; 'but': 0.35; 'keyword': 0.36; 'charset:us-ascii': 0.36; 'two': 0.37; 'list': 0.37; 'bad': 0.39; 'called': 0.40; 'skip:u 10': 0.60; 'most': 0.60; 'name': 0.63; 'choose': 0.64; 'to:addr:gmail.com': 0.65; 'between': 0.67; 'invalid': 0.68; 'further,': 0.74; 'avoids': 0.84; 'received:50.22': 0.84; 'subject:Don': 0.91; 'whereas': 0.91
Date Mon, 10 Jun 2013 19:46:40 -0500
From Tim Chase <python.list@tim.thechases.com>
To Mark Janssen <dreamingforward@gmail.com>
Subject Re: "Don't rebind built-in names*" - it confuses readers
In-Reply-To <CAMjeLr9w4iCFv=kgUdBTqgNgHpXh-AWGgxwR3tF=O=oX-DKtyA@mail.gmail.com>
References <kp5q5o$fj1$1@ger.gmane.org> <CAMjeLr8X_M+zp1zkSGV_wUTyv_e6XCbfhpTmzVzy2t5PuONEjQ@mail.gmail.com> <CAMjeLr9w4iCFv=kgUdBTqgNgHpXh-AWGgxwR3tF=O=oX-DKtyA@mail.gmail.com>
X-Mailer Claws Mail 3.7.6 (GTK+ 2.20.1; x86_64-pc-linux-gnu)
Mime-Version 1.0
Content-Type text/plain; charset=US-ASCII
Content-Transfer-Encoding 7bit
X-AntiAbuse This header was added to track abuse, please include it with any abuse report
X-AntiAbuse Primary Hostname - boston.accountservergroup.com
X-AntiAbuse Original Domain - python.org
X-AntiAbuse Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse Sender Address Domain - tim.thechases.com
Cc python-list@python.org, Terry Jan Reedy <tjreedy@udel.edu>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
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.3003.1370911490.3114.python-list@python.org> (permalink)
Lines 33
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1370911490 news.xs4all.nl 15868 [2001:888:2000:d::a6]:40348
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:47624

Show key headers only | View raw


On 2013-06-10 17:20, Mark Janssen wrote:
> >>         list = []
> >> Reading further, one sees that the function works with two
> >> lists, a list of file names, unfortunately called 'list',
> >
> > That is very good advice in general:  never choose a variable name
> > that is a keyword.
> 
> Btw,  shouldn't it be illegal anyway?  Most compilers don't let you
> do use a keyword as a variable name....

There's a subtle difference between a keyword and a built-in.  Good
Python style generally avoids masking built-ins but allows it:

  >>> "file" in dir(__builtins__)
  True
  >>> file = "hello" # bad style, but permitted
  >>> print file
  hello

Whereas the compiler prevents you from tromping on actual keywords:

  >>> for = 4
    File "<stdin>", line 1
      for = 4
          ^
  SyntaxError: invalid syntax

-tkc



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


Thread

Re: "Don't rebind built-in names*" - it confuses readers Tim Chase <python.list@tim.thechases.com> - 2013-06-10 19:46 -0500

csiph-web