<分区> 分区>
Possible Duplicate:
Does python have an equivalent to Java Class.forName()?
我正在使用 appengine 开发应用程序。理想情况下,我想像这样定义一个新种类(称为 Recipe):
class Recipe(db.Model):
ingredients = db.ListProperty(type)
quantities = db.ListProperty(int)
但是,您似乎不能使用“type”作为 ListProperty 中的类值。我正在考虑不使用 ListProperty,而是使用 ListStringProperty 并将类名保存为字符串。但是,如何将字符串转换为类名,这样我就可以这样写:
str = "A"
# convert str to class name in var class_str
class_str().call_some_method()
提前致谢,
何塞
