[Python-Dev] syntactic support for sets
Steven Bethard
steven.bethard at gmail.com
Wed Feb 1 22:58:41 CET 2006
Raymond Hettinger wrote:
> [Phillip J. Eby]
> > The only case that looks slightly less than optimal is:
> >
> > set((1, 2, 3, 4, 5))
> >
> > But I'm not sure that it warrants a special syntax just to get rid of the
> > extra ().
>
> The PEP records that Tim argued for leaving the extra parentheses.
> What would you do with {'title'} -- create a four element set consisting
> of letters or a single element set consisting of a string?
I think the answer to this one is clearly that it is a single element
set consisting of a string, just as ['title'] is a single element list
consisting of a string.
I believe the confusion arises if Brett's proposal for ``set(1, 2, 3,
4, 5)`` is considered. Currently, set('title') is a five element set
consisting of letters. But set('title', 'author') would be a two
element set consisting of two strings? The problem is in calling the
set constructor, not in writing a set literal.
That said, I don't think there's really that much of a need for set
literals. I use sets almost exclusively to remove duplicates, so I
almost always start with empty sets and add things to them. And I'm
certainly never going to write ``set([1, 1, 2])`` when I could just
write ``set([1, 2])`.
STeVe
--
You can wordify anything if you just verb it.
--- Bucky Katt, Get Fuzzy
More information about the Python-Dev
mailing list