hyp*_*ean 2 python refactoring
I have lots of small pieces of code that look like:
for it in <iterable>:
if <condition>:
return True/False
Run Code Online (Sandbox Code Playgroud)
Is there a way I can rewrite this piece of code with a lambda expression ? I know I can factor it out in a small method/function, but I am looking for some lambda thing if it can be done.
使用内置any 功能.
例如
any(<condition> for it in <iterable>) # return True on <condition>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
180 次 |
| 最近记录: |