How can I 'update' a class that has already been declared? My particular scenario is allowing a user to enter code (via a module name) during runtime to update the class when the program determines that the existing class is insufficient. So let's say I have module ClassA
containing
class ClassA:
def __init__(self, field1):
self.field1 = field1
partway through runtime I notice some cases where I'd like to use ClassA
if only I could add another field. I alert the user to this and give them the option. What can I prompt them to input? Is it possible for them to give me a filename redeclaring the class? If not, how else would I be able to do this? And if the user does this, what happens to existing instances of the class? I assume they are seamlessly updated if this is done correctly?