class CD(object):
def __init__(self,id,name,singer):
self._id = id
self.n = name
self.s = singer
def get_info(self):
info = 'self._id'+':'+ ' self.n' +' self.s'
return info
class collection(object):
def __init__(self):
cdfile = read('CDs.txt','r')
I have a file 'CDs.txt' which has a list of tuples look like this:
[
("Shape of you", "Ed Sheeran"),
("Shape of you", "Ed Sheeran"),
("I don't wanna live forever", "Zayn/Taylor Swift"),
("Fake Love", "Drake"),
("Starboy", "The Weeknd"),
......
]
Now in my collection class, I want to create a CD object for each tuple in my list and save them in a data structure. I want each tuple to have a unique id number, it doesn't matter they are the same, they need to have different id....can anyone help me with this?