Pickle performing class instantiation ??

2012-02-28 Thread Smiley 4321
I am looking for pickle performing class instantiation, something as prototype like - - Have a class - Instantiate the class with 3 parameters - pickle the class instance - generate a bytestream (.pkl) using pickle.dump -- http://mail.python.org/mailman/listinfo/python-list

Re: Pickle performing class instantiation ??

2012-02-28 Thread Smiley 4321
:44 PM, Smiley 4321 ssmil...@gmail.com wrote: I am looking for pickle performing class instantiation, something as prototype like - - Have a class - Instantiate the class with 3 parameters - pickle the class instance - generate a bytestream (.pkl) using pickle.dump -- http

RE: Pickle performing class instantiation ??

2012-02-28 Thread Prasad, Ramit
class Pickle:     def __init__(self, Parameter1, Parameter2, Parameter3):         self.PM1 = Parameter1         self.PM2 = Parameter2         self.PM3 = Parameter3 with open('/tmp/readfile.pkl', 'wb') as f:     pickle.dump((self.PM1, self.PM2, self.PM3), f)     with open('/tmp/readfile.pkl',

Re: Pickle performing class instantiation ??

2012-02-28 Thread Peter Otten
Smiley 4321 wrote: Am I doing the right thing for - - Have a class - Instantiate the class with 3 parameters - pickle the class instance - generate a bytestream (.pkl) using pickle.dump, simply guessing - as - --- #!/usr/bin/python import pickle class Pickle: def

Re: Pickle performing class instantiation ??

2012-02-28 Thread Andrew Berg
On 2/28/2012 9:54 AM, Smiley 4321 wrote: NameError: name 'self' is not defined self is meaningless outside a class definition. You should refactor your dump, load and print code as methods inside the class definition, create an instance and call the methods on that instance. -- CPython 3.2.2 |