How to pickle a subclass of tuple?

Christos TZOTZIOY Georgiou tzot at
Thu Jun 3 18:26:37 CEST 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