列表我来自爪哇,我希望做一些data transfer objects(DTO的)是这样的:定义类型
class ErrorDefinition():
code = ''
message = ''
exception = ''
class ResponseDTO():
sucess = True
errors = list() # How do I say it that it is directly of the ErrorDefinition() type, to not import it every time that I'm going to append an error definition?
还是有更好的方式来做到这一点?
虽然这可能是真实的,类型提示是什么,让我们的生活更加美好,并帮助您避免愚蠢的错误。请参阅:https://www.python.org/dev/peps/pep-0484/ – Pretzel 2016-01-26 16:16:18
Python有可选的类型检查。这是针对问题的精神以及语言的意图和能力的建议。 – ggranum 2017-12-10 17:00:27