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 __init__(self, Parameter1, Parameter2,
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',
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
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 |