I’m trying to find a way to create and later reference a class that was defined not inside of actual python code.
I tried using the exec() function to execute lines of code that would create a class, but since python is an interpreted language I am under the assumption that this will not be a viable option. Here is the code that I tried:
def con(var, mt, todo):
exec(f'''
class {var}:
def __init__(self, x):
self.x = x
def {mt}(self):
exec(todo)
{var} = Pleth{i}(7)
''')
New contributor
boaconstructor is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.