calling a method using a variable name?

Patrick Price no-email at nowhere.com
Fri Mar 14 15:49:59 EST 2003


Can I call a method of a class using a variable, eg:

class X:
   def method():
      pass


z=X."method"()

How would I do this?  I need to call different methods (read from a 
list) without hardcoding them in the program.

Thanks in advance,
  -Patrick Price
  (jp at moment.net)





More information about the Python-list mailing list