I’m tring to create class instances in a loop. All instances need to be assinged to a different variable. These variables can be a sequence of letters like [a,b,c].
class MyClass(object):
pass
for i in something:
#create an instance
If the loop turns 3 times, I want the loop make something like that:
a = MyClass()
b = MyClass()
c = MyClass()
Is there a way to do that?
you could have a list of the names you want to name the objects and then in the loop you add the names to the global namespace as you create and name the objects.
People here will definitely say this is a bad way to code without giving any cogent reason but it directly solves your problem without any further list or dict.