Am I doing the right thing for -<br><br>- Have a class<br>- Instantiate the class with 3 parameters<br>- pickle the class instance<br>- generate a bytestream (.pkl) using pickle.dump, simply guessing -<br><br>as -<br><br>---<br>
#!/usr/bin/python<br><br>import pickle<br><br>class Pickle:<br>    def __init__(self, Parameter1, Parameter2, Parameter3):<br>        self.PM1 = Parameter1<br>        self.PM2 = Parameter2<br>        self.PM3 = Parameter3<br>
        <br>with open('/tmp/readfile.pkl', 'wb') as f:<br>    pickle.dump((self.PM1, self.PM2, self.PM3), f)<br>    <br>with open('/tmp/readfile.pkl', 'rb') as f:<br>    self.PM1, self.PM2, self.PM3 = pickle.load(f)<br>
<br>print self.PM1<br>print self.PM2<br>print self.PM3<br>----<br><div class="gmail_quote"><br>but I get an error message as - <br><br>-----<br>$ ./class-test1.py<br>Traceback (most recent call last):<br>  File "./class-test1.py", line 12, in <module><br>
    pickle.dump((self.PM1, self.PM2, self.PM3), f)<br>NameError: name 'self' is not defined<br>------<br><br>On Tue, Feb 28, 2012 at 8:44 PM, Smiley 4321 <span dir="ltr"><<a href="mailto:ssmile03@gmail.com">ssmile03@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I am looking for pickle performing class instantiation, something as prototype like -<br><br>- Have a class<br>- Instantiate the class with 3 parameters<br>
- pickle the class instance<br>- generate a bytestream (.pkl) using pickle.dump<br>
<br><br>
</blockquote></div><br>