unpickling Set as set

Nick Vatamaniuc vatamane at gmail.com
Wed Nov 8 07:51:56 CET 2006

The two are not of the same type:

In : import sets
In : s1=sets.Set([1,2,3])

In : s2=set([1,2,3])

In: type(s1)
Out: <class 'sets.Set'>

In : type(s2)
Out: <type 'set'>

In : s1==s2
Out: False   # oops!

In: s2==set(s1)
Out: True   # aha!

You'll have to just cast:

-Nick V.

Amir  Michail wrote:
> Hi,
> Is there an easy way to unpickle the older Set as the newer set behind
> the scenes when using shelve?
> Amir

More information about the Python-list mailing list