On Thu, 12 May 2011 11:33:37 -0500 (CDT) Skip Montanaro <skip at 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.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4