775 def parse_postfix(self, node: nodes.Expr) -> nodes.Expr: 776 while True: 777 token_type = self.stream.current.type 778 if token_type == "dot" or token_type == "lbracket": 779 node = self.parse_subscript(node) 780 # calls are valid both after postfix expressions (getattr 781 # and getitem) as well as filters and tests
To check if a variable is equal to one of many values, combine the values into a tuple and check if the variable is contained
in it instead of checking for equality against each of the values.
This is faster, less verbose, and more readable.
if x == 1 or x == 2 or x == 3: do_something()
if x in (1, 2, 3): do_something()