“status”类表示某个事件的状态。
statuses的Python项目详细描述
状态
Status
类表示某个事件的状态。它是
或者:
Failed
NotStarted
InProgress(progress)
Succeeded
安装
$ pip install statuses
示例
fromtypingimportIterablefromstatusimportInProgress,Failed,NotStarted,SucceededclassReport:def__init__(self:"Report"):self.status=NotStarted()defrun(self:"Report",foo:str,bar:Iterable[int]):iffoo=="badstring":self.status=Failed()fori,binenumerate(bar):self.status=InProgress(i/len(bar)*100)print(self.status)self.status=Succeeded()r=Report()print(r.status)r.run("goodstring",range(10))print(r.status)
文档
难看的文档可以在 docs/index.html。