Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.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; 'python,': 0.01; 'newbie': 0.03; '(except': 0.05; 'warnings': 0.05; 'builtins': 0.07; 'subject:when': 0.07; 'python': 0.08; 'builtin': 0.09; 'programmer': 0.10; 'am,': 0.12; '16,': 0.15; 'helpful,': 0.16; 'later).': 0.16; 'otoh,': 0.16; 'subject:builtin': 0.16; 'this)': 0.16; 'wrote:': 0.16; 'seems': 0.20; 'suggest': 0.20; "aren't": 0.21; 'header:In-Reply-To:1': 0.22; '(or': 0.23; 'default,': 0.23; "shouldn't": 0.23; 'asked': 0.23; 'variable': 0.24; 'aug': 0.24; 'helpful': 0.26; 'posted': 0.26; 'environment': 0.29; "won't": 0.29; 'accidentally': 0.30; 'config': 0.30; 'discussion.': 0.30; 'if,': 0.30; 'zero.': 0.30; 'subject:?': 0.31; 'list': 0.32; 'installed': 0.32; "isn't": 0.33; 'sort': 0.33; 'it.': 0.33; 'there': 0.33; 'to:addr:python-list': 0.33; 'instead': 0.33; 'someone': 0.34; 'all.': 0.34; 'pretty': 0.35; 'anything': 0.36; 'charset:us-ascii': 0.36; 'question': 0.36; 'doing': 0.36; 'variables': 0.37; 'response': 0.37; 'rest': 0.37; 'using': 0.37; 'but': 0.37; 'could': 0.38; 'think': 0.38; 'configured': 0.38; 'steven': 0.38; 'subject:: ': 0.39; 'suggestions': 0.39; 'option': 0.39; 'enough': 0.39; 'help': 0.39; 'user': 0.39; 'to:addr:python.org': 0.39; 'where': 0.40; 'thinking': 0.40; 'one- time': 0.67; 'special': 0.67; 'received:209.167': 0.84; 'specific,': 0.84 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: RE: Why no warnings when re-assigning builtin names? X-MimeOLE: Produced By Microsoft Exchange V6.5 Date: Tue, 16 Aug 2011 13:15:04 -0400 In-Reply-To: <4e49fcd7$0$29974$c3e8da3$5496439d@news.astraweb.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Why no warnings when re-assigning builtin names? Thread-Index: AcxcOAnyayrvPTcPQLWSQkyIomkurA== References: <4e49c89a$0$30001$c3e8da3$5496439d@news.astraweb.com> <4e49fcd7$0$29974$c3e8da3$5496439d@news.astraweb.com> From: "Gerrat Rickert" To: 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: 44 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1313514908 news.xs4all.nl 23836 [2001:888:2000:d::a6]:42988 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:11586 > On Aug 16, 2011, at 1:15 AM, Steven D'Aprano wrote: ... > A warning that is off by default won't help the people who need it, > because > they don't know enough to turn the warning on. A warning that is on by > default will be helpful to the newbie programmer for the first week or > so, > and then will be nothing but an annoyance for the rest of their career. >=20 I think that best practices would suggest that one shouldn't use variable=20 names that shadow builtins (except in specific, special circumstances),=20 so I don't really think this would be an annoyance at all. The number of *unwanted* warnings they'd get would be pretty close to zero. OTOH, in=20 response to a question I asked on StackOverflow, someone posted a large=20 list of times where this isn't followed in the std lib, so there seems=20 to be a precedent for just using the builtin names for anything=20 one feels like at the time. Thinking about it, what about if, by default, python was configured to emit warnings about this sort of thing, but a simple environment variable or config option would turn them off. That way, new users would get warnings when doing this sort of thing, and any experienced user that wanted the option of using these variables anywhere would just have a one-time thing to change=20 when they installed python (or any time later). They'd turn these warnings off when they installed Python, and would never have to think about it again. New=20 users (or experienced ones that prefer this) would be warned by default, and then could make the conscious decision to shadow the builtin names,=20 instead of accidentally doing it. All the suggestions to just use a linter aren't helpful, since=20 new users aren't likely to start with one & and they are the thrust=20 of this discussion. =20