【文件属性】:
文件名称:smoothie:基于 Python 异常的回调
文件大小:9KB
文件格式:ZIP
更新时间:2021-05-29 15:55:43
Python
冰沙
安装
pip install smoothie
例子
基于 Python 异常的回调
将您的回调作为装饰器添加到函数中,这些函数将根据引发的异常进行调用。
from smoothie . king import Dispenser
def err_callback ( * args , ** kwargs ):
print ( "Error handled" )
juice = Dispenser ()
@ juice . attach ( exception = IndexError ,
callback = err_callback )
def vending_machine ():
drinks = [ 'Tea' , 'Coffee' , 'Water' ]
return drinks [ 4 ]
vendin
【文件预览】:
smoothie-master
----test-requirements.txt(4B)
----.gitignore(691B)
----setup.cfg(583B)
----README.md(796B)
----LICENSE(11KB)
----requirements.txt(0B)
----setup.py(99B)
----.travis.yml(196B)
----smoothie()
--------tests()
--------king.py(1KB)
--------exc()
--------__init__.py(22B)