Skip to content

Latest commit

 

History

History
19 lines (12 loc) · 366 Bytes

use-a-generator.md

File metadata and controls

19 lines (12 loc) · 366 Bytes

Pattern: Use of comprehension in any/all

Issue: -

Description

Comprehension inside of any or all is unnecessary. A generator would be sufficient and faster.

Example of incorrect code:

any([0 for x in list(range(10))]) # [use-a-generator]

Example of correct code:

any(0 for x in list(range(10)))