Yes, using eval is a bad practice. Just to name a few reasons:
In your case you can use setattr instead:
classSong:"""The class to store the details of each song"""
attsToStore=('Name','Artist','Album','Genre','Location')def __init__(self):for att in self.attsToStore:
setattr(self, att.lower(),None)def setDetail(self, key, val):if key in self.attsToStore:
setattr(self, key.lower(), val)