I have a class where I want to call different modules form it, depending on an input from the user.
In my mind it would look something like this:
class Test:
def test1:
print("Hello world")
def test2:
print("farewell world")
user = input("> ")
Test.f{user}
Where it now will call what the user has told it to, but it doesn't work. So my question is if it's possible, if it is then how I would accomplish it.
When trying examples from the given link, I keep encountering a problem for example where it tells me
"TypeError: test1() takes 0 positional arguments but 1 was given"
when the input looks like so:
getattr(globals()['Test'](), 'test')()
this is not the only one, and all I have tried leads to problems. leading me to believe that either my problem is different, or I'm implementing it wrong.
Help with either scenario is much a appreciate.