def ClassHopperMutant(initial_object, class_returning_callable, copy=True):
from copy import copy as _copy<EOL>def class_mutator(obj):<EOL><INDENT>obj.__class__ = class_returning_callable(obj)<EOL>return obj<EOL><DEDENT>if copy:<EOL><INDENT>initial_object = _copy(initial_object)<EOL><DEDENT>return OnAccessMutant(initial_object, class_mutator)<EOL>
ClassHopper: a wrapper that reevaluates the class of the wrapped instance
on every access attempt.
It's like obj.__class__ = callable_returning_a_class(),
but magically happening before every manipulation with the object.

Usage: mutant.ClassHopper(initial_object, callable_returning_a_class)