Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.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.010 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'warnings': 0.05; 'forcing': 0.07; 'subject:when': 0.07; 'suppress': 0.07; 'bars': 0.09; 'invocation': 0.09; 'am,': 0.12; 'def': 0.15; 'confusing.': 0.16; 'executed;': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'subject:builtin': 0.16; 'twice.': 0.16; 'wrote:': 0.16; 'wed,': 0.17; 'seems': 0.20; 'header:In-Reply-To:1': 0.22; "shouldn't": 0.23; 'aug': 0.24; "i'm": 0.27; 'language.': 0.28; 'message-id:@mail.gmail.com': 0.29; '(and': 0.29; 'lines': 0.30; 'subject:?': 0.31; 'chris': 0.32; 'list': 0.32; 'too': 0.33; 'there': 0.33; 'to:addr:python- list': 0.33; 'however,': 0.34; '17,': 0.34; 'flag': 0.34; 'useful': 0.36; 'another': 0.37; 'assuming': 0.37; 'statements': 0.37; 'list,': 0.37; 'but': 0.37; 'two': 0.37; 'some': 0.38; 'received:google.com': 0.38; 'received:209.85': 0.38; 'should': 0.38; 'subject:: ': 0.39; 'user': 0.39; 'session': 0.39; 'to:addr:python.org': 0.39; 'case': 0.39; "i'd": 0.40; "it's": 0.40; 'provided': 0.60; 'huge': 0.61; 'easily': 0.61; 'cost': 0.65; 'greatest': 0.73; 'been?': 0.84; 'many.': 0.84; 'preferred,': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=+9+187pnjtLi1jBA5u3QD+t4n3IV99wXUYQABNRhD10=; b=l19aID7ViGTpd3ESu9jc7RDsmSY12tkSbTb7UJYVLoq38dJFPfXqcB3KU2vrkS3kHq NBlmlJle9QtaDh1Dpi7gWU996zT/pfE7hsiF+QuLqRks2ZU/vP1QcnZaLzOy72UXk//N JvS7hlS1+Wo6EwOh3DdJgXn7WoY5n6SqVNMfM= MIME-Version: 1.0 In-Reply-To: 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> Date: Wed, 17 Aug 2011 08:27:44 +0100 Subject: Re: Why no warnings when re-assigning builtin names? From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 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: 37 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1313566067 news.xs4all.nl 23934 [2001:888:2000:d::a6]:60984 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:11662 On Wed, Aug 17, 2011 at 2:35 AM, Seebs wrote: > On 2011-08-17, Chris Angelico wrote: >> It mightn't be very significant, but there'd still be some cost. >> However, IMHO the greatest cost is the spamminess; forcing the user to >> deal with lines and lines of warnings is not a useful way to design a >> language. > > Lines and lines? > > I'd say if it's to be allowed to shadow built-ins (and I'm not sure that's > a good thing at all), you'd still be looking at one warning per shadowing, > which shouldn't be too many. One warning per shadowing. Okay. def foo(list): """Foo's the list provided and returns True on success or False on failure.""" def bar(list): """Counts the number of bars in the list, assuming it to be made of music.""" if not foo(list): return You call foo() once and bar() twice. How many shadowings have there been? How many warnings do you get? A simple implementation would give five warnings for this case - once for each invocation that shadows a builtin. Another simple implementation would give two warnings, at the time that the def statements are executed; this is preferred, but it's still two warnings, and if you have a huge set of functions that do this, that can easily be "lines and lines" of warnings. Or should it set a flag and say "I've already warned this session about shadowing 'list', so suppress all others"? That seems confusing. ChrisA