【文件属性】:
文件名称:posmatch:自定义类的位置子模式匹配
文件大小:5KB
文件格式:ZIP
更新时间:2021-03-25 22:16:27
Python
自定义类的位置子模式匹配。
要求
Python 3.8或更高版本。
注意:该程序包本身不需要Python 3.10,但是它的用法仅对Python 3.10中引入的新模式匹配功能有意义。
安装
pip install posmatch
用法
例子1
使用pos_match装饰器。
from posmatch import pos_match
@ pos_match
class Color :
def __init__ ( self , r , g , b ):
self . r = r
self . g = g
self . b = b
color = Color ( 64 , 64 , 64 )
match color :
case Color ( r , g , b ) if r == g == b :
【文件预览】:
posmatch-master
----README.rst(2KB)
----posmatch()
--------__init__.py(161B)
--------core.py(1KB)
----LICENSE(1KB)
----setup.py(1KB)
----tests()
--------unit_test.py(9KB)
--------matching.py(360B)