python object AttributeError: type object 'Track' has no attribute 'title'
- by ccwhite1
I apologize if this is a noob question, but I can't seem to figure this one out.
I have defined an object that defines a music track
(NOTE: originally had the just ATTRIBUTE vs self.ATTRIBUTE. I edited those values in to help remove confusion. They had no affect on the problem)
class Track(object):
def __init__(self, title, artist, album, source, dest):
"""
Model of the Track Object
Contains the followign attributes:
'Title', 'Artist', 'Album', 'Source', 'Dest'
"""
self.atrTitle = title
self.atrArtist = artist
self.atrAlbum = album
self.atrSource = source
self.atrDest = dest
I use ObjectListView to create a list of tracks in a specific directory
....other code....
self.aTrack = [Track(sTitle,sArtist,sAlbum,sSource, sDestDir)]
self.TrackOlv.AddObjects(self.aTrack)
....other code....
Now I want to iterate the list and print out a single value of each item
list = self.TrackOlv.GetObjects()
for item in list:
print item.atrTitle
This fails with the error
AttributeError: type object 'Track' has no attribute 'atrTitle'
What really confuses me is if I highlight a single item in the Object List View display and use the following code, it will correctly print out the single value for the highlighted item
list = self.TrackOlv.GetSelectedObject()
print list.atrTitle