[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


Hi

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(" ")
	args[0].args[1]
class calculate:
	def bundle(self):
		print __class__
command_dispatcher()

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:

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

shell returned 1



More information about the Tutor mailing list