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

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -