Why this fails??
Smiley 4321
ssmile03 at gmail.com
Wed Feb 29 04:07:55 EST 2012
More information about the Python-list mailing list
Wed Feb 29 04:07:55 EST 2012
- Previous message (by thread): Problem using s.strip() to remove leading whitespace in .csv file
- Next message (by thread): Why this fails??
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Why below fails -
----
#!/usr/bin/python
import pickle
class MyClass(object):
Field1 = None
Field2 = None
def __init__(self, dictionary):
self.__dict__.update(dictionary)
my_List = {'Field1': 'Apple', 'Field2': 'Orange'}
myInst = MyClass(my_List)
with open('/tmp/readfile.pkl', 'wb') as f:
pickle.dump(myInst, f)
----
with below error messges -
$ ./pickleClassWrite.py
Traceback (most recent call last):
File "./pickleClassWrite.py", line 5, in <module>
class MyClass(object):
File "./pickleClassWrite.py", line 14, in MyClass
myInst = MyClass(my_List)
NameError: name 'MyClass' is not defined
---
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120229/049078d2/attachment.html>
- Previous message (by thread): Problem using s.strip() to remove leading whitespace in .csv file
- Next message (by thread): Why this fails??
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list