I'm trying to create variable names such as:
event1
event2
event3
to name different instances of the same class.
I searched online, and a lot of people are suggesting dictionary. But as far as I know, dictionary only works for pairs. I want to name different instances of the same class, for example:
class Event:
def __init__(self, description):
self.__description = description
event1 = Event('This is event 1')
event2 = Event('This is event 2')
event3 = Event('This is event 3')
Does anyone know how I can do that? Thanks in advance.
Edit 1:
It appears my question was not clear enough. I do not know how many instances are needed. I will read the length of a file (the number of lines in the file), and then create instances of the class.
Edit 2:
I have multiple pieces of information to fill in the class. For example:
class Event:
def __init__(self, name, description, value):
self.__name = name
self.__description = description
self.__value = value
event1 = Event('This is event 1', 'Tom eats apple', '20')
event2 = Event('This is event 2', 'Jerry eats pie', '10')
#......
#(maybe 20 or more)