If you have a list of all the potions, this is simple:
potion_names = [p.name for p in list_of_potions]
If you do not have such a list, it is not so simple; you'd better maintain such a list by adding potions to the list or, better yet, a dictionary, explicitly.
You can use the dictionary to add potions when creating instances potions:
all_potions = {}
class potions:
def __init__(self, name, attribute, harmstat, cost):
self.name = name
self.attribute = attribute
self.harmstat = harmstat
self.cost = cost
all_potions[self.name] = self
:
all_potion_names = all_potions.keys()
:
all_potions['Freezing Potion']