[Python-3000] sets in P3K?
Ian Bicking
ianb at colorstudy.com
Wed Apr 26 17:48:33 CEST 2006
Toby Dickenson wrote:
> On Wednesday 26 April 2006 09:03, Talin wrote:
>
>
>>In my experience dict literals are far more useful than set literals.
>>In fact, I don't think I've ever made a set literal. The only
>>syntactical short cut that I would find useful for a set would
>>be "new empty set", for which I think "set()" is probably short
>>enough already.
>
>
> I quite often write....
>
> if state in (case1,case2,case3):
>
> as a shorter form of....
>
> if state==case1 or state==case2 or state==case3:
Yes, this is what I do; for small static sets inlined into source code
lists or tuples are slightly more convenient, and so I'd never use a set
in that situation without a set literal.
I don't know if this points one way or the other, but that sets are only
built up out of sequences is a byproduct of the (lack of) syntax, which
makes people use lists for sets; it's not that literal sets aren't
useful. OTOH, lists and tuples are a perfectly workable alternative to
sets, so maybe it doesn't matter much.
--
Ian Bicking / ianb at colorstudy.com / http://blog.ianbicking.org
More information about the Python-3000
mailing list