Skip to content

SIM108: Use the ternary operator if it's reasonable. #12

@MartinThoma

Description

@MartinThoma

Explanation

Use the ternary operator if it's reasonable.

Example

# Bad
if a:
    b = c
else:
    b = d

# Good
b = c if a else d

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