Set to string. Obvious:
>>> s = set([1,2,3])
>>> s
set([1, 2, 3])
>>> str(s)
'set([1, 2, 3])'
String to set? Maybe like this?
>>> set(map(int,str(s).split('set([')[-1].split('])')[0].split(',')))
set([1, 2, 3])
Extremely ugly. Is there better way to serialize/deserialize sets?
pickle
, but that's a misleading assumption in this case. – Ellisellison