Title: Consider specialized syntax error for `&&` and `||` · Issue #146495 · python/cpython · GitHub
Open Graph Title: Consider specialized syntax error for `&&` and `||` · Issue #146495 · python/cpython
X Title: Consider specialized syntax error for `&&` and `||` · Issue #146495 · python/cpython
Description: 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...
Open Graph Description: 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 ope...
X Description: 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...
Opengraph URL: https://github.com/python/cpython/issues/146495
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Consider specialized syntax error for `&&` and `||`","articleBody":"# Feature or enhancement\n\n### Proposal:\n\nComing 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.\n\nIt could be helpful to add a specialized syntax error. Something like:\n```python\n File \"\u003cpython-input-1>\", line 1\n a && b\n ^^\nSyntaxError: invalid syntax. Maybe you meant 'and' or '&' instead of '&&'?\n```\n\nThis 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.\n\ncc @pablogsal @lysnikolaou\n\n### Has this already been discussed elsewhere?\n\nThis is a minor feature, which does not need previous discussion elsewhere\n\n### Links to previous discussion of this feature:\n\n_No response_\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-150906\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/brianschubert","@type":"Person","name":"brianschubert"},"datePublished":"2026-03-26T21:46:59Z","url":"https://github.com/python/cpython/issues/146495"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:dd9a6bd2-f567-89bf-cfd7-4c9f6b42c4fb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E9BC:380435:A2C480:CD5550:6B021F4E |
| html-safe-nonce | f0d21cc946fee307f8dab0f88b477d96409a5d572293b77a07d97b2756d0adc7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOUJDOjM4MDQzNTpBMkM0ODA6Q0Q1NTUwOjZCMDIxRjRFIiwidmlzaXRvcl9pZCI6IjIwNjQ1Mjk5MzQxODA4MTg3NjYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | bae0bba966935a7c107673c12e316235db87d0e648b307533de5c89ba6cbd079 |
| hovercard-subject-tag | issue:4147538625 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/146495/issue_layout |
| twitter:image | https://opengraph.githubassets.com/075ed7f91304c85841f9713e1bd14b4eb74c331b432a8482f81bdc352abb974f/python/cpython/issues/146495 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/075ed7f91304c85841f9713e1bd14b4eb74c331b432a8482f81bdc352abb974f/python/cpython/issues/146495 |
| og:image:alt | 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 ope... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | brianschubert |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width