Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!xlned.com!feeder7.xlned.com!news2.euro.net!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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.01; 'plenty': 0.03; 'warnings': 0.05; 'builtins': 0.07; 'subject:when': 0.07; 'python': 0.08; 'builtin': 0.09; 'deliberately': 0.09; 'highlight': 0.09; 'not?': 0.09; 'examples': 0.11; 'am,': 0.12; 'library': 0.15; '16,': 0.15; '"i\'m': 0.16; 'grep': 0.16; 'highlighting': 0.16; 'n00bs': 0.16; 'received:mindspring.com': 0.16; 'semanchuk': 0.16; 'subject:builtin': 0.16; 'such.': 0.16; 'sure,': 0.16; 'x-mailer:apple mail (2.1084)': 0.16; 'wrote:': 0.16; '>>>': 0.18; 'to:name:python-list': 0.18; 'seems': 0.20; 'detect': 0.21; 'sound': 0.21; 'header:In-Reply-To:1': 0.22; 'cheers': 0.23; 'int,': 0.23; 'somehow': 0.23; 'variable': 0.24; 'there.': 0.24; 'aug': 0.24; 'times,': 0.24; 'do,': 0.25; 'code': 0.25; 'fine': 0.26; "i'm": 0.27; 'somebody': 0.28; 'all,': 0.28; 'raise': 0.28; 'problem': 0.28; 'looks': 0.29; 'not.': 0.30; 'times.': 0.30; 'harm': 0.30; 'str': 0.30; 'subject:?': 0.31; 'changes': 0.31; 'changing': 0.31; 'cases': 0.32; 'word.': 0.32; 'received:24': 0.32; 'yet': 0.32; 'source': 0.33; "isn't": 0.33; 'sort': 0.33; "what's": 0.33; 'actually': 0.33; 'probably': 0.33; "can't": 0.33; 'to:addr:python-list': 0.33; 'regardless': 0.34; 'done': 0.34; 'yourself.': 0.34; 'things': 0.34; 'all.': 0.34; 'advocate': 0.34; 'trouble': 0.35; 'charset:us-ascii': 0.36; 'file': 0.36; 'issue': 0.36; 'skip:" 10': 0.36; 'opposed': 0.37; 'using': 0.37; 'but': 0.37; 'something': 0.37; 'open': 0.37; 'could': 0.38; 'think': 0.38; 'strong': 0.38; 'steven': 0.38; 'subject:: ': 0.39; 'header:Mime-Version:1': 0.39; 'either': 0.39; "there's": 0.39; 'meaning': 0.39; 'to:addr:python.org': 0.39; 'might': 0.40; "it's": 0.40; 'where': 0.40; 'more': 0.60; 'hope': 0.61; 'header:Message-Id:1': 0.61; 'further': 0.64; 'sincerely': 0.64; 'believe': 0.65; 'cost': 0.65; 'anything,': 0.73; 'protecting': 0.73; 'average': 0.77; '"yes,': 0.84; '11:41': 0.84; 'bitten': 0.84; 'contributors': 0.84; 'message?': 0.84; 'received:69.73': 0.84; 'serious.': 0.84; 'warning.': 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: <4E4A8F94.50706@stoneleaf.us> Date: Tue, 16 Aug 2011 11:38:57 -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> <4E4A8F94.50706@stoneleaf.us> To: 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: 76 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1313509143 news.xs4all.nl 23852 [2001:888:2000:d::a6]:36461 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:11567 On Aug 16, 2011, at 11:41 AM, Ethan Furman wrote: > Philip Semanchuk wrote: >> On Aug 16, 2011, at 1:15 AM, Steven D'Aprano wrote: >>> Protecting n00bs from their own errors is an admirable aim, but have = you >>> considered that warnings for something which may be harmless could = do more >>> harm than good? >> Isn't the whole point of a warning to highlight behavior that's not = strictly > > wrong but looks iffy? Sort of, "I can't be sure, but this looks like = trouble > > to me. I hope you know what you're doing". If we are to eschew = warnings in > > cases where they might be highlighting something harmless, then we = would > > have no warnings at all. >=20 > Sounds good to me. ;) Keep such things in the IDE's, and then those = who desire such behavior can have it there. Do not clutter Python with = such. You wink, yet you sound serious. What's with the mixed message? Do you = honestly advocate removing all warnings from Python, or not? I sincerely = would like to know what you think. >>> Perhaps. But I'm not so sure it is worth the cost of extra code to = detect >>> shadowing and raise a warning. After all, the average coder probably = never >>> shadows anything, >> 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 > What makes you think it's unintentional? file makes a good variable = name, and if you don't need it to actually open a file there's nothing = wrong with using it yourself. "Unintentional" as in, "I'm using file as a variable name because it's = handy" as opposed to intentional as in "Yes, I am deliberately changing = the meaning of this builtin".=20 >>> and for those that do, once they get bitten *once* they >>> either never do it again or learn how to shadow safely. >> I have done it plenty of times, never been bitten (thankfully) and = still > > do it by accident now and again. >=20 > Seems to me the real issue is somebody using a builtin, such as str or = int, and that they somehow manage to do this without realizing, "wait a = sec', that's one of my variables!" =20 Yes > I don't see that as a problem that Python needs to solve. "need" is a strong word. Python will be fine regardless of whether this = changes or not. I believe Python could be improved; that's all I'm = arguing. Cheers Philip