[Tutor] How to use a str object, to find the class in exact name?

Yaşar Arabacı yasar11732 at gmail.com
Mon Mar 14 22:15:53 CET 2011


I am trying to do something like this:

#!/usr/bin/env python
def command_dispatcher():
	"Takes comman line arguments and executes regardin method"
	command = raw_input(">>>")
	args = command.split(" ")
class calculate:
	def bundle(self):
		print __class__

What I need this to do is, take a raw input, split it into parts and 
execute class args[0] and method args[1] using args[2:] as an argument. 
But what I have done isn't working. This is the error I get:

 >>>calculate bundle
Traceback (most recent call last):
   File "/home/yasar/best_buy/main.py", line 10, in <module>
   File "/home/yasar/best_buy/main.py", line 6, in command_dispatcher
AttributeError: 'str' object has no attribute 'args'

shell returned 1

More information about the Tutor mailing list