django过滤器风格的Python谓词函数
predicate的Python项目详细描述
谓词
Predicate采用django queryset过滤语言,并将其应用于构建python本地谓词函数
您可以传递给filter
内置函数。在
此库旨在使创建本机python过滤器函数变得易读且容易:
>>>frompredicateimportwhere>>>people=[...{'name':{'first':'Joe','last':'Smith'},'age':25},...{'name':{'first':'Jane','last':'Smith'},'age':27},...{'name':{'first':'John','last':'Smith'},'age':33},...{'name':{'first':'Bill','last':'Bob'},'age':40},...{'name':{'first':'Joe','last':'Bob'},'age':59},...]>>>young_smiths=list(filter(where(name__last__iexact='smith',age__lte=30),people))>>>young_smiths[{'name':{'first':'Joe','last':'Smith'},'age':25},{'name':{'first':'Jane','last':'Smith'},'age':27}]
安装
此项目通过pip
分发。要开始:
- 项目
标签: