PEP 8's guidance on whitespace in expressions and statements (the "Pet Peeves" section) explicitly states that whitespace should be avoided immediately before the open parenthesis that starts a function call's argument list — for example, spam(1) is correct, while spam (1) is not. It also explicitly states that no whitespace should appear between a trailing comma and a following closing parenthesis — for example, foo = (0,) is correct, while bar = (0, ) is not. By contrast, PEP 8 recommends avoiding whitespace immediately before a comma, semicolon, or colon (not adding it), and it recommends avoiding extraneous whitespace immediately inside/before brackets used for indexing or slicing (not adding whitespace after the opening bracket).
Community Discussion