Python 3 Attributeerror Even Though Attribute Exists
Solution 1:
I figured out where I went wrong! My program is associated with a file called myMemory.dat
which stores a pickled version of a Memory
object and is loaded and saved with each run of the program. The Memory
object is essentially a list of ENTRY
s to be queried. At the time when I updated all of my code to use the name name
instead of nickname
, I already had hundreds of ENTRY
objects saved in myMemory.dat
- each an instance of the old ENTRY
object with a nickName
attribute instead of a name
attribute. When I called functions which attempted to access the ENTRY
object's name
attribute, the program threw an error because the ENTRY
objects in question did not have that attribute.
The fix: I looped through the Memory
object stored in myMemory.dat
and copied all of the info into new ENTRY
s in a new Memory
object. I saved the new Memory
to myMemory.dat
, and the program works good as new!
Post a Comment for "Python 3 Attributeerror Even Though Attribute Exists"