Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In compound expressions, don't add whitespace inside terms #60

Open
rhettinger opened this issue Jan 22, 2022 · 0 comments
Open

In compound expressions, don't add whitespace inside terms #60

rhettinger opened this issue Jan 22, 2022 · 0 comments

Comments

@rhettinger
Copy link

Per PEP8:

If operators with different priorities are used, consider adding whitespace around the operators with the lowest priority(ies). Use your own judgment; however, never use more than one space, and always have the same amount of whitespace on both sides of a binary operator:

# Correct:
i = i + 1
submitted += 1
x = x*2 - 1
hypot2 = x*x + y*y
c = (a+b) * (a-b)

Note that SymPy does the right thing, so we know there is enough semantic information to do this correctly:

>>> from sympy import var
>>> var('x')
x
>>> ((3*x + 5) * (2*x - 4)).expand()
6*x**2 - 2*x - 20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant