Skip to content

SIM110 / SIM111: Use any / all #15

@MartinThoma

Description

@MartinThoma

Explanation

It's shorter.

Example 1: any

# Bad
for x in iterable:
    if check(x):
        return True
return False

# Good
return any(check(x) for x in iterable)

Example 2: all

# Bad
for x in iterable:
    if check(x):
        return False
return True

# Good
return all(check(x) for x in iterable)

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions