Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #3642

Re: List comprehension vs filter()

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 <chris@rebertia.com>
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 <BANLkTimvUPXRKOvGNqDzNCJp0UuWT1AkVg@mail.gmail.com>
References <BANLkTin4KMcoWzfH64Eu=+sD9=M3TaAu2A@mail.gmail.com> <BANLkTinVhX1jDd5brOh1D1m4zU5R8pEoSQ@mail.gmail.com> <BANLkTimvUPXRKOvGNqDzNCJp0UuWT1AkVg@mail.gmail.com>
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 <clp2@rebertia.com>
To Chris Angelico <rosuav@gmail.com>
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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.609.1303271126.9059.python-list@python.org> (permalink)
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

Show key headers only | View raw


On Tue, Apr 19, 2011 at 8:23 PM, Chris Angelico <rosuav@gmail.com> wrote:
> On Wed, Apr 20, 2011 at 1:22 PM, Chris Rebert <clp2@rebertia.com> wrote:
>> On Tue, Apr 19, 2011 at 8:10 PM, Chris Angelico <rosuav@gmail.com> wrote:
>> <snip>
>>> 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
<built-in function len>
>>> len = 5
>>> len
5
>>> del len
>>> len
<built-in function len>
>>> del len
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'len' is not defined
>>> len
<built-in function len>

Cheers,
Chris
--
http://rebertia.com

Back to comp.lang.python | Previous | Next | Find similar


Thread

Re: List comprehension vs filter() Chris Rebert <clp2@rebertia.com> - 2011-04-19 20:45 -0700

csiph-web