Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'programmer': 0.03; 'guido': 0.05; 'url:pipermail': 0.05; '"""': 0.07; 'made.': 0.07; 'variables': 0.07; 'string': 0.09; 'builtin': 0.09; 'hiding': 0.09; 'mask': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'rossum': 0.09; 'jan': 0.12; 'builtins': 0.16; 'clashes': 0.16; 'long-time': 0.16; 'open()': 0.16; 'posters': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'reedy': 0.16; 'stumbling': 0.16; 'url:)': 0.16; 'wrote:': 0.18; '(not': 0.18; 'variable': 0.18; 'header:User-Agent:1': 0.23; 'library,': 0.24; 'post': 0.26; 'header:X-Complaints-To:1': 0.27; 'van': 0.27; 'idea': 0.28; "i'm": 0.30; 'code': 0.31; 'fixing': 0.31; 'name;': 0.31; 'file': 0.32; 'class': 0.32; 'probably': 0.32; 'url:python': 0.33; 'alone': 0.33; 'except': 0.35; 'case,': 0.35; 'but': 0.35; 'impression': 0.36; 'url:org': 0.36; 'changing': 0.37; 'being': 0.38; 'expected': 0.38; 'to:addr :python-list': 0.38; 'to:addr:python.org': 0.39; 'changed': 0.39; 'received:org': 0.40; 'url:mail': 0.40; 'future': 0.60; 'most': 0.60; 'matter': 0.61; 'name': 0.63; 'kept': 0.65; 'worth': 0.66; 'past.': 0.68; 'obvious': 0.74; 'wave': 0.74; 'checkin': 0.84; 'nod': 0.84; 'url:python-dev': 0.84; 'subject:Don': 0.91; 'hands': 0.96 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Peter Otten <__peter__@web.de> Subject: Re: "Don't rebind built-in names*" - it confuses readers Date: Tue, 11 Jun 2013 09:09:32 +0200 Organization: None References: Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Gmane-NNTP-Posting-Host: p5084afc3.dip0.t-ipconnect.de User-Agent: KNode/4.7.3 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 40 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1370934571 news.xs4all.nl 15990 [2001:888:2000:d::a6]:55500 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:47643 Terry Jan Reedy wrote: > Many long-time posters have advised "Don't rebind built-in names*. I'm in that camp, but I think this old post by Guido van Rossum is worth reading to put the matter into perspective: """ > That was probably a checkin I made. I would have left it alone except the > code was > > file = open(...) > > As long as I was changing the variable name to not mask the builtin I > changed the call as well. Had it been > > f = open(...) > > I probably would have kept my hands off. Hm... I'm not particularly concerned over fixing all code that uses file as a local variable name, unless it actually is likely to need to reference the file class by name; builtins are in the last scope searched for the very reason that no programmer is expected to keep up with all additions to the built-in library, so locals hiding built-ins is okay. (Not that it isn't a good idea to avoid obvious clashes -- 'str' for string variables and 'type' for type variables being the most obvious stumbling blocks.) > In any case, I was under the impression that file() was the wave of the > future and open() a nod to the past. Now you know better... --Guido van Rossum (home page: http://www.python.org/~guido/) """