python - Call method from string -
If I have a python class and want to call it a function, depending on one variable, How will i I could think of it after the following:
class CallMe: # Class Diff app (): # method one ... def foo (): # method two ... variable = "app "# CallMe.variable calling method () #Colling app ()
But is it not possible to do any other way of doing this?
You can:
Getattr (Columns, Variables ) ()
is an underlying method, it gives the value of the multiplied name of the object. In this case the value is a method object that you can call from ()
Comments
Post a Comment