Package of modules that encapsulate the if else multi-condition judgment
Project description
ProjectName
ProjectName and Description
"优雅的if-else替换"
优化并美观你的if-else
探索本项目的文档 »
查看Demo
·
报告Bug
·
提出新特性
目录
文件目录说明
conditionevaluatortool
├── /conditionevaluator/
│ ├── __init__.py
│ ├── conditionevaluator.py
├── /test/
│ ├── __init__.py
│ ├── test.py
├── README.md
└── setup.py
上手指南
环境要求
- Python 3.7.0
安装依赖包
- pip install conditionevaluator
使用步骤
1.在需要做多条件判断的函数中引入装饰器
import conditionevaluator
@conditionevaluator
def doorType(door):
"""
条件1
:param door: 门类型 2 --> 双开门
:return: bool
"""
return "门类型错误"
2.其他函数调用
@doorType.register(1)
def params_door_type_1(door):
"""
条件1
:param door:
:return: False
"""
count = 1
return count
@doorType.register(2)
def params_door_type_2(door):
"""
条件2
:param door:
:return: True
"""
count = 2
return count
3.测试
if __name__ == '__main__':
print(params_door_type_2(1))
# 结果输出
>>> 2
使用到的框架
暂无
版本控制
该项目使用Git进行版本管理。您可以在repository参看当前可用版本。
作者
cywhat
- 🔗个人博客
鸣谢
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.