Re: cPickle - sharing pickled objects between scripts and imports

2012-06-25 Thread Rotwang
On 24/06/2012 00:17, Steven D'Aprano wrote: On Sat, 23 Jun 2012 19:14:43 +0100, Rotwang wrote: The problem is that if the object was pickled by the module run as a script and then unpickled by the imported module, the unpickler looks in __main__ rather than mymodule for the object's class, and

Re: cPickle - sharing pickled objects between scripts and imports

2012-06-23 Thread Steven D'Aprano
On Sat, 23 Jun 2012 19:14:43 +0100, Rotwang wrote: > The problem is that if the object was > pickled by the module run as a script and then unpickled by the imported > module, the unpickler looks in __main__ rather than mymodule for the > object's class, and doesn't find it. Possibly the solutio

Re: cPickle - sharing pickled objects between scripts and imports

2012-06-23 Thread Rotwang
On 23/06/2012 18:31, Dave Angel wrote: On 06/23/2012 12:13 PM, Peter Otten wrote: Rotwang wrote: Hi all, I have a module that saves and loads data using cPickle, and I've encountered a problem. Sometimes I want to import the module and use it in the interactive Python interpreter, whereas some

Re: cPickle - sharing pickled objects between scripts and imports

2012-06-23 Thread Rotwang
On 23/06/2012 17:13, Peter Otten wrote: Rotwang wrote: Hi all, I have a module that saves and loads data using cPickle, and I've encountered a problem. Sometimes I want to import the module and use it in the interactive Python interpreter, whereas sometimes I want to run it as a script. But obj

Re: cPickle - sharing pickled objects between scripts and imports

2012-06-23 Thread Dave Angel
On 06/23/2012 12:13 PM, Peter Otten wrote: > Rotwang wrote: > >> Hi all, I have a module that saves and loads data using cPickle, and >> I've encountered a problem. Sometimes I want to import the module and >> use it in the interactive Python interpreter, whereas sometimes I want >> to run it as a

Re: cPickle - sharing pickled objects between scripts and imports

2012-06-23 Thread Peter Otten
Rotwang wrote: > Hi all, I have a module that saves and loads data using cPickle, and > I've encountered a problem. Sometimes I want to import the module and > use it in the interactive Python interpreter, whereas sometimes I want > to run it as a script. But objects that have been pickled by runn

cPickle - sharing pickled objects between scripts and imports

2012-06-23 Thread Rotwang
Hi all, I have a module that saves and loads data using cPickle, and I've encountered a problem. Sometimes I want to import the module and use it in the interactive Python interpreter, whereas sometimes I want to run it as a script. But objects that have been pickled by running the module as a