[Python-3000] sets in P3K?

Toby Dickenson tdickenson at devmail.geminidataloggers.co.uk
Wed Apr 26 10:56:00 CEST 2006


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:

That is definitely a set membership test, although there probably is little 
advantage in using a Set object rather than a tuple for this.
-- 
Toby Dickenson


More information about the Python-3000 mailing list