[Tutor] Sets are cool

Kent Johnson kent_johnson at skillsoft.com
Wed Oct 27 16:48:28 CEST 2004

At 08:27 AM 10/27/2004 -0600, Mike Hansen wrote:
> >>> from sets import Set
>sets are new to version 2.3. I thought I had read that they might be 
>built_in in 2.4. Anyone know?

Yes, sets are cool, and yes, they are a built in type in Python 2.4.  See 
here for details: http://www.python.org/dev/doc/devel/whatsnew/node2.html

Actually Python 2.4 supports both the older 'sets.Set' and the 'set' 
built-in, which should be faster since it is implemented in C. If you want 
to write code that works under both you could use something like this:

except NameError:
   from sets import Set as set

Then you can use set from either version of Python.


More information about the Tutor mailing list