[Tutor] sets module equivalent with Python 2.6

PyProg PyProg pyprog05 at gmail.com
Tue Mar 17 22:34:42 CET 2009


Hello all,

I want to use an equivalent of sets module with Python 2.6 ... but
sets module is deprecated on 2.6 version.

In fact I want to make that but with Python 2.6:

>>> toto_1 = [0, 1, 2, 3, 4]
>>> toto_2 = [1, 127, 4, 7, 12]
>>>
>>> import sets
>>> a = sets.Set(toto_1)
>>> b = sets.Set(toto_2)
>>> c = a.symmetric_difference(b)
>>> d = [p for p in c]
>>> d.sort()
>>> print d
[0, 2, 3, 7, 12, 127]

Can you help me ?.

Thanks in advance.

a+

-- 
http://ekd.tuxfamily.org


More information about the Tutor mailing list