I have a code similar to this:
if command == "print":
foo_obj.print()
if command == "install":
foo_obj.install()
if command == "remove":
foo_obj.remove()
command is a string (I define it by parsing command line arguments, but that’s beyond the point). Is there a way to replace the above chunck of code with something similar to this?
foo_obj.function(command)
For the recored I’m using Python 2.7
The core function may be as:
Of course, you should allow only certain methods: