Python 2.7 parser bug on syntax for set literals ?

Steve Holden steve at holdenweb.com
Sun Oct 24 01:38:09 EDT 2010


Geremy and the parser are correct - it *is* a set. It would only be a
dict if you changed the comma to a colon.

regards
 Steve


On 10/24/2010 1:31 AM, Steve Howe wrote:
> Hello Geremy,
> 
> The whole point is, is not supposed to be a set; a set literal would
> end with "})". As you can see, there is no such construct in the
> string.
> It's just a dict inside parentheses. Somehow, the parser seems to
> think it's a set.
> 
> --
> Howe
> howesteve at gmail.com
> 
> 
> 
> On Sun, Oct 24, 2010 at 2:58 AM, geremy condra <debatem1 at gmail.com> wrote:
>> On Sat, Oct 23, 2010 at 9:40 PM, Steve Howe <howesteve at googlemail.com> wrote:
>>> Hello,
>>>
>>> This looks like a parser bug, but it's so basic I'm in doubt. Can
>>> anyone confirm ?
>>>
>>>>>> import sys
>>>>>> sys.version
>>> '2.7.0+ (r27:82500, Sep 15 2010, 18:14:55) \n[GCC 4.4.5]'
>>>>>> ({'', 1}.items())
>>> Traceback (most recent call last):
>>>  File "<stdin>", line 1, in <module>
>>> AttributeError: 'set' object has no attribute 'items'
>>
>> I'm not clear on what the bug is supposed to be, as this looks right
>> to me. Or are you trying to make a dictionary and getting thrown by
>> the set syntax?
>>
>> Geremy Condra
>>


-- 
Steve Holden           +1 571 484 6266   +1 800 494 3119
PyCon 2011 Atlanta March 9-17       http://us.pycon.org/
See Python Video!       http://python.mirocommunity.org/
Holden Web LLC                 http://www.holdenweb.com/




More information about the Python-list mailing list