[Python-3000] Set literal

Guido van Rossum guido at python.org
Sat Jan 26 03:23:55 CET 2008


On Jan 25, 2008 4:58 PM, Ron Adam <rrr at ronadam.com> wrote:
> How about also removing the {} as an empty dictionary?  Then both
> dictionary and set literals will require at least one item to be valid.No
>   confusion, and {} is not allowed because it's ambiguous (to users) as to
> weather it's a set or dictionary.

That sounds like punishing the dict type for something it didn't do.

> Would set({a, b, c}) be valid?

Can't see how it couldn't be. :-)

> If so, should the repr for a set be set({a, b, c}) instead of
> set([a, b, c])?

Of course. In current 3.0 the frozenset() repr() already does this:

>>> frozenset([1,2,3])
frozenset({1, 2, 3})
>>>

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list