On Thu, 12 May 2011 11:33:37 -0500 (CDT) Skip Montanaro <s...@montanaro.dyndns.org> wrote: > > A friend at work who is new to Python wondered why this didn't work with > pickle: > > class Outer: > > Class Inner: > > ... > > def __init__(self): > self.i = Outer.Inner() > [...] > > I've never questions this, but I wonder, is this a fundamental restriction > or could it be overcome with a modest amount of work?
pickle uses heuristics to try to find out the "official name" of a class or function. It would be a matter of improving these heuristics. There are other cases in which pickle similarly fails: >>> pickle.dumps(random.random) b'\x80\x03crandom\nrandom\nq\x00.' >>> pickle.dumps(random.randint) Traceback (most recent call last): File "<stdin>", line 1, in <module> _pickle.PicklingError: Can't pickle <class 'method'>: attribute lookup builtins.method failed Regards Antoine. _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com