可能重复:
Does python have an equivalent to Java Class.forName()?将字符串转换(从AppEngine上的数据存储类)
我使用AppEngine上开发应用程序。理想我想定义一种新的(称为配方)是这样的:
class Recipe(db.Model):
ingredients = db.ListProperty(type)
quantities = db.ListProperty(int)
但是似乎你不能使用“类型”中的ListProperty类值。我想的不是使用ListProperty,而是使用ListStringProperty并将类名称保存为字符串。然而,如何将字符串转换为一个类名,这样我就可以这样写:提前
str = "A"
# convert str to class name in var class_str
class_str().call_some_method()
感谢,
何塞
也许这个问题的答案会帮助你:[python是否具有与Java的Class.forName()?](http://stackoverflow.com/questions/452969/) – gclj5 2010-01-23 08:24:44