Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!feeder2.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.84.MISMATCH!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.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'context': 0.04; '3.2': 0.05; 'subject:when': 0.07; 'variable,': 0.07; 'python': 0.08; 'builtin': 0.09; "'file')": 0.16; '(eg': 0.16; 'alternative,': 0.16; 'code).': 0.16; 'common.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'subject:builtin': 0.16; 'windows).': 0.16; 'wrote:': 0.16; 'wed,': 0.17; '(like': 0.21; "doesn't": 0.22; 'header:In-Reply-To:1': 0.22; 'pm,': 0.24; 'variable': 0.24; 'aug': 0.24; 'fine': 0.26; 'described': 0.28; 'message-id:@mail.gmail.com': 0.29; 'second': 0.29; 'allowed,': 0.30; 'equivalent': 0.31; 'subject:?': 0.31; 'changing': 0.31; 'it.': 0.33; 'probably': 0.33; 'to:addr:python-list': 0.33; '17,': 0.34; 'do?': 0.34; 'problem.': 0.36; 'another': 0.37; 'using': 0.37; 'but': 0.37; 'something': 0.37; 'received:google.com': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.39; 'to:addr:python.org': 0.39; 'greatly': 0.40; "it's": 0.40; 'where': 0.40; 'extremely': 0.40; 'your': 0.61; 'back': 0.62; 'exact': 0.68; 'proud': 0.70; 'million': 0.74; '(based': 0.84; 'deliberate': 0.84 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:content-transfer-encoding; bh=aTTutqtTJ9tqG6eeiAOO47fr8ack6iO0g9ORAydffEI=; b=wQLK0A6Rv2ptb2NyrgN8qry/RakEtiz7HQqsf55r2yQiBKgxd/j4luAq2JCSa98QtT WWKS5RD0V4BzmbzvxY8/TnCPW9/92aWPAS4DYRmp9tWNWzCWKb3AIzYVU8BFCuO3dZQ1 azJDVPJLHMfpyR0OaDRF3aD97KKS0j3aTsaXI= MIME-Version: 1.0 In-Reply-To: References: <4e49c89a$0$30001$c3e8da3$5496439d@news.astraweb.com> <4e49fcd7$0$29974$c3e8da3$5496439d@news.astraweb.com> <4e4b1242$0$29966$c3e8da3$5496439d@news.astraweb.com> <4e4b7898$0$29974$c3e8da3$5496439d@news.astraweb.com> Date: Wed, 17 Aug 2011 18:42:26 +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 Content-Transfer-Encoding: quoted-printable 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: 27 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1313602949 news.xs4all.nl 23836 [2001:888:2000:d::a6]:56285 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:11704 On Wed, Aug 17, 2011 at 5:33 PM, Seebs wrote: > If it's such a bad thing, *why is it allowed*? =A0Why are you proud of th= e > ability to do something that you are never socially-allowed to do? > Going back to my original three examples: > 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. All three are allowed, but it's the first one that's considered unusual. The second one is simply that Python doesn't have a million and one reserved words. Yes, you probably don't want to use 'print' as a variable name, but shadowing it with an exact equivalent would be fine (eg to automatically date-stamp or log your output, without changing your code). And as described above, using list/str/id etc is not uncommon. I greatly prefer this to the alternative, which is another 133 reserved words (based on Python 3.2 for Windows). ChrisA