brianschubert · GitHub

Feature or enhancement

Proposal:

Coming from other languages, it’s easy to accidentally write && or || in place of and or or. I've even seen experienced people reach for them when doing boolean operations on Numpy arrays and the like.

It could be helpful to add a specialized syntax error. Something like:

  File "<python-input-1>", line 1
    a && b
      ^^
SyntaxError: invalid syntax. Maybe you meant 'and' or '&' instead of '&&'?

This might be a little tricky, since && and || are not their own tokens, so I don't think this can be done at the grammar level.

cc @pablogsal @lysnikolaou

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

Read the original on github.com ↗