0

I currently have an object instance lets call it myObject. This myObject has methods like executeX, executeY etc. I want to pass this methods as strings such that I can do something like command = data.get('do') then myObject.command and have command be treated as an attribute. How can I achieve this??

Aran-Fey
  • 39,665
  • 11
  • 104
  • 149
E_K
  • 2,159
  • 23
  • 39
  • You can't. `myObject.command` will access the attribute *named command*, the object also named command is uninvolved. If you want to access attributes from a string of their name, use `getattr`. – jonrsharpe Mar 10 '19 at 16:18
  • Thanks for this. @Aran-Fey – E_K Mar 10 '19 at 16:21

0 Answers0