例如:
# field base class
class F:
pass
# represent integer
class AF(F):
pass
# represent string
class BF(F):
pass
class M:
a = AF()
b = BF()
def __init__(self):
pass # generate dynamic attrs based on specified static attrs
m = M()
# m.a should have inferred type integer
也许它只是IDE(PyCharm)特性和所有这些类型提示,而这个特性是硬绑定到django的Model
类的?你知道吗
Django的模型类有显式检查字段类型的字段,以及将这些类型添加到DB的数据库迁移。如果想在python中使用静态类型,可以考虑使用MyPy来注释函数和变量。你知道吗
相关问题 更多 >
编程相关推荐