Re: Difference between list() and [] with dictionaries

2009-05-16 Thread Ned Deily
In article , a...@pythoncraft.com (Aahz) wrote: > In article , > Ned Deily wrote: > >The second example is a call to the built-in function "list", [...] > Actually, list() is not a function: > >>> list > > Rather, ``list`` is an object (specifically a ``type`` object) with a > __call__() meth

Re: Difference between list() and [] with dictionaries

2009-05-16 Thread Aahz
In article , Ned Deily wrote: >In article >, > Sam Tregar wrote: >> >> Can anyone explain why this creates a list containing a >> dictionary: >> [{'a': 'b', 'foo': 'bar'}] >> But this creates a list of keys of the dictionary: >> list({ "a": "b", "foo": "bar" }) > >The first example is a li

Re: Difference between list() and [] with dictionaries

2009-05-15 Thread Ned Deily
In article , Sam Tregar wrote: > Can anyone explain why this creates a list containing a > dictionary: > [{'a': 'b', 'foo': 'bar'}] > But this creates a list of keys of the dictionary: > list({ "a": "b", "foo": "bar" }) The first example is a list, expressed as a list display literal, con

Re: Difference between list() and [] with dictionaries

2009-05-15 Thread Gabriel Genellina
En Fri, 15 May 2009 22:17:43 -0300, Sam Tregar escribió: Hello all. Can anyone explain why this creates a list containing a dictionary: [{'a': 'b', 'foo': 'bar'}] But this creates a list of keys of the dictionary: list({ "a": "b", "foo": "bar" }) I expected them to be equivalent but cl

Difference between list() and [] with dictionaries

2009-05-15 Thread Sam Tregar
Hello all. Can anyone explain why this creates a list containing a dictionary: [{'a': 'b', 'foo': 'bar'}] But this creates a list of keys of the dictionary: list({ "a": "b", "foo": "bar" }) I expected them to be equivalent but clearly they're not! I'm using Python 2.6.1 if that helps. -s