I'm not 100% sure I understand what you want, but my guess is you want
something like this:
# A toy class.
class AClass(object):
def __init__(self, astring):
self.astring = astring
def __repr__(self):
return "%s(%r)" % (self.__class__.__name__, self.astring)
# And some variations.
class BClass(AClass):
pass
class CClass(AClass):
pass
# Build a dispatch table, mapping the class name to the class itself.
TABLE = {}
for cls in (AClass, BClass, CClass):
TABLE[cls.__name__] = cls
# Get the name of the class, and an argument, from the command line.
# Or from the user. Any source of two strings will do.
# Data validation is left as an exercise.
import sys
argv = sys.argv[1:]
if not argv:
name = raw_input("Name of the class to use? ")
arg = raw_input("And the argument to use? ")
argv = [name, arg]
# Instantiate.
instance = TABLE[argv[0]](argv[1])
print instance
--
Steven