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


Groups > comp.lang.python > #3642

Re: List comprehension vs filter()

References <BANLkTin4KMcoWzfH64Eu=+sD9=M3TaAu2A@mail.gmail.com> <BANLkTinVhX1jDd5brOh1D1m4zU5R8pEoSQ@mail.gmail.com> <BANLkTimvUPXRKOvGNqDzNCJp0UuWT1AkVg@mail.gmail.com>
Date 2011-04-19 20:45 -0700
Subject Re: List comprehension vs filter()
From Chris Rebert <clp2@rebertia.com>
Newsgroups comp.lang.python
Message-ID <mailman.609.1303271126.9059.python-list@python.org> (permalink)

Show all headers | 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