Skip to content Skip to sidebar Skip to footer

Python 3 Attributeerror Even Though Attribute Exists

I have a set of python files which make up a program for saving tidbits of info and searching them via tag association. I had the program working for many versions, but I recently

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 ENTRYs 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 ENTRYs 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"