Is any() evaluated lazily?

前端 未结 7 486
别跟我提以往
别跟我提以往 2021-01-18 03:59

I am writing a script in which i have to test numbers against a number of conditions. If any of the conditions are met i want to return True an

7条回答
  •  遥遥无期
    2021-01-18 04:25

    No. All and Any support shortcircuiting but they don't make the conditionals interpretation lazy.

    If you want an All or Any using lazy evaluation you need to pass them a generator. Or else the values get evaluated in the moment the list/set/iterator/whatever is constructed

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题