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!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; 'wed,': 0.04; 'python': 0.07; 'interpreting': 0.09; 'nameerror:': 0.09; 'subject:()': 0.09; 'pm,': 0.11; '>>>': 0.12; 'essentially': 0.12; 'received:74.125.82.44': 0.14; 'received:mail-ww0-f44.google.com': 0.14; 'wrote:': 0.14; 'defined': 0.15; 'len': 0.16; 'rebert': 0.16; 'traceback': 0.16; '(most': 0.16; 'subject:List': 0.20; 'tue,': 0.20; 'cc:no real name:2**0': 0.20; 'cc:2**0': 0.20; 'cheers,': 0.20; 'variable': 0.21; 'jan': 0.22; 'header:In-Reply- To:1': 0.22; "aren't": 0.22; 'cc:addr:python-list': 0.22; 'last):': 0.23; 'name?': 0.23; 'creating': 0.26; "i'm": 0.26; 'chris': 0.27; 'message-id:@mail.gmail.com': 0.28; 'changing': 0.29; 'class': 0.29; 'cc:addr:python.org': 0.31; 'exists,': 0.31; 'file': 0.35; '"",': 0.35; 'right?': 0.35; 'quite': 0.36; '20,': 0.38; 'apr': 0.38; 'received:google.com': 0.38; 'but': 0.38; 'how': 0.39; 'header:Received:5': 0.40; 'results': 0.61; '2011': 0.62 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=domainkey-signature:mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=dDNz1K+6a6yXXFcHmeP+wgQVfdYf+peWTQ21MV68y14=; b=EUMLuTNdT1ceXoAsQFL+/nsjTIO5tLbOpbrBByWy7br81YR6NJ1m0/vcOVMgpA3AeL a15f9tfEF9v1Kv5GwY6tmKQDHk/y/aF9wJMMYtEIkVabmKpbBN6iGXptoqsXGC3tXrhC rLbiJUJCV77Qx1KqpGGC8VWZME/qjIlJemdL8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=rebertia.com; s=google; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; b=eyyMKn6ZjbIm31xInQM/tRxczmquA4bD1rwYN6SI3LJPSHEz78ry9pn4bAdfvoOFsx u20o3w5OldXHNlG5ydN4NCpPc2uQsUkk+erGO+2trd0GLLZRQBWMY6mQbPfqOWtsgVzP sOhrHkkp4JfBcvUdN9i1ApC14j8b/L9AdihJ0= MIME-Version: 1.0 Sender: chris@rebertia.com In-Reply-To: References: Date: Tue, 19 Apr 2011 20:45:25 -0700 X-Google-Sender-Auth: 5sva2sdrMP-Vs-JO_byMGKxETtQ Subject: Re: List comprehension vs filter() From: Chris Rebert To: Chris Angelico Content-Type: text/plain; charset=UTF-8 Cc: python-list@python.org 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: 35 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1303271127 news.xs4all.nl 81474 [::ffff:82.94.164.166]:35933 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:3642 On Tue, Apr 19, 2011 at 8:23 PM, Chris Angelico wrote: > On Wed, Apr 20, 2011 at 1:22 PM, Chris Rebert wrote: >> On Tue, Apr 19, 2011 at 8:10 PM, Chris Angelico wrote: >> >>> type=lst[0]["type"].lower() >> >> Tangent: Don't call it "type"; you're shadowing the built-in class of >> the same name. > > By "shadowing" you mean that the global variable still exists, right? > I'm creating a local variable with the same name? That's how I'm > interpreting the results of changing the variable name. Built-ins aren't quite the same as globals, but essentially yes: $ python Python 2.6.6 (r266:84292, Jan 12 2011, 13:35:00) >>> len >>> len = 5 >>> len 5 >>> del len >>> len >>> del len Traceback (most recent call last): File "", line 1, in NameError: name 'len' is not defined >>> len Cheers, Chris -- http://rebertia.com