How to pickle a subclass of tuple?

Christos TZOTZIOY Georgiou tzot at sil-tec.gr
Thu Jun 3 12:26:37 EDT 2004


__getstate__ is easy:

def __getstate__(self):
    return tuple(self)

but even

def __getstate__(self):
    return self

seems to work, as far as Pickle.dump is concerned.  The problem is, how
one writes a __setstate__ for an immutable class?
-- 
TZOTZIOY, I speak England very best,
"I have a cunning plan, m'lord" --Sean Bean as Odysseus/Ulysses



More information about the Python-list mailing list