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??
Asked
Active
Viewed 25 times
0
Aran-Fey
- 35,525
- 9
- 94
- 135
Esir Kings
- 1,849
- 19
- 31
-
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 – Esir Kings Mar 10 '19 at 16:21