[issue24612] not operator expression raising a syntax error

candide report at bugs.python.org
Sat Jul 11 17:23:53 CEST 2015


New submission from candide:

Expressions such as

a + not b
a * not b
+ not b
- not b

raise a SyntaxError, for instance :


>>> 0 + not 0
  File "<stdin>", line 1
    0 + not 0
          ^
SyntaxError: invalid syntax
>>> - not 0
  File "<stdin>", line 1
    - not 0
        ^
SyntaxError: invalid syntax
>>>

if the not expression is wrapped in parenthesis, expected evaluation occurs:


>>> - not 0
  File "<stdin>", line 1
    - not 0
        ^
SyntaxError: invalid syntax
>>> 0 + (not 0)
1
>>> - (not 0)
-1
>>>



The problem has been first submitted in comp.lang.python :

https://groups.google.com/forum/?hl=fr#!topic/comp.lang.python/iZiBs3tcuak


suggesting  a bug report.

----------
components: Interpreter Core
messages: 246606
nosy: candide, serhiy.storchaka
priority: normal
severity: normal
status: open
title: not operator expression raising a syntax error
type: behavior
versions: Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24612>
_______________________________________


More information about the Python-bugs-list mailing list