in comparisons, variables must be left

Cette page n'est pas encore disponible en français, sa traduction est en cours.
Si vous avez des questions ou des retours sur notre projet de traduction actuel, n'hésitez pas à nous contacter.

Metadata

ID: python-best-practices/comparison-constant-left

Language: Python

Severity: Notice

Category: Best Practices

Description

In a comparison that compare a variable with a value, put the variable on the left side of the comparison expression.

Non-Compliant Code Examples

if 1 <= i:  # use i >= 1
  pass
if 1.0 <= i:  # use i >= 1.0
  pass

Compliant Code Examples

if i >= 1:
  pass

if 0 < nextSx <= len(subject):
    px = nextPx
    sx = nextSx

if 1 in ctx:
  print("foo")
https://static.datadoghq.com/static/images/logos/github_avatar.svg https://static.datadoghq.com/static/images/logos/vscode_avatar.svg jetbrains

Seamless integrations. Try Datadog Code Analysis

PREVIEWING: rtrieu/product-analytics-ui-changes