Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'context': 0.04; 'builtins': 0.07; 'subject:when': 0.07; 'variable,': 0.07; 'python': 0.08; 'builtin': 0.09; 'either.': 0.09; 'examples': 0.11; 'am,': 0.12; 'library': 0.15; '16,': 0.15; "'file')": 0.16; '11:12': 0.16; 'common.': 0.16; 'grep': 0.16; 'received:mindspring.com': 0.16; 'semanchuk': 0.16; 'subject:builtin': 0.16; 'trap': 0.16; 'x-mailer:apple mail (2.1084)': 0.16; 'wrote:': 0.16; '(like': 0.21; 'header:In-Reply- To:1': 0.22; 'cheers': 0.23; 'tue,': 0.23; 'pm,': 0.24; 'variable': 0.24; 'aug': 0.24; 'code': 0.25; 'times.': 0.30; 'subject:?': 0.31; 'chris': 0.32; 'received:24': 0.32; 'source': 0.33; 'it.': 0.33; 'actually': 0.33; 'there': 0.33; 'to:addr :python-list': 0.33; 'setting': 0.34; 'charset:us-ascii': 0.36; 'problem.': 0.36; 'file': 0.36; 'using': 0.37; 'several': 0.37; 'but': 0.37; 'strong': 0.38; 'subject:: ': 0.39; 'header:Mime- Version:1': 0.39; 'to:addr:python.org': 0.39; 'where': 0.40; 'extremely': 0.40; 'header:Message-Id:1': 0.61; 'further': 0.64; 'contributors': 0.84; 'deliberate': 0.84; 'received:69.73': 0.84; 'dozens': 0.91 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Apple Message framework v1084) Subject: Re: Why no warnings when re-assigning builtin names? From: Philip Semanchuk In-Reply-To: Date: Tue, 16 Aug 2011 11:31:30 -0400 Content-Transfer-Encoding: quoted-printable References: <4e49c89a$0$30001$c3e8da3$5496439d@news.astraweb.com> <4e49fcd7$0$29974$c3e8da3$5496439d@news.astraweb.com> <2A3EB048-1F10-46E8-973F-9BBD303E7B9F@semanchuk.com> To: Lista-Comp-Lang-Python list X-Mailer: Apple Mail (2.1084) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - deimos.nocdirect.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - semanchuk.com 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: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1313508696 news.xs4all.nl 23954 [2001:888:2000:d::a6]:34022 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:11566 On Aug 16, 2011, at 11:12 AM, Chris Angelico wrote: > On Tue, Aug 16, 2011 at 3:13 PM, Philip Semanchuk = wrote: >=20 >> One need look no further than the standard library to see a strong = counterexample. grep through the Python source for " file =3D". I see = dozens of examples of this builtin being used as a common variable name. = I would call contributors to the standard library above-average coders, = and we can see them unintentionally shadowing builtins many times. >>=20 >=20 > There are several types of shadowing: >=20 > 1) Deliberate shadowing because you want to change the behavior of the > name. Extremely rare. > 2) Shadowing simply by using the name of an unusual builtin (like > 'file') in a context where you never use it. Very common. > 3) Unintentional shadowing where you create a variable, but then > intend to use the builtin. This is the only one that's a problem. Yes, but before you get to #3 you have to go through #2. The way I see = it, #2 is setting a trap, #3 is actually stepping in it. I don't want to = do either. Neither do I like working with code that has set trap #2 for = me. Cheers Philip=