[New-bugs-announce] [issue11381] pretending the "not" operator is a function behaves surprisingly

Abafei report at bugs.python.org
Thu Mar 3 06:44:40 CET 2011

New submission from Abafei <abafei at gmail.com>:

I'm not sure if this is a bug per se, since I don't think pretending operators are callable is in the docs, but:

pretending an operator (at least the "not" operator) is callable, like so:

can be surprising:
>>> (not 1) == 9

>>> not(1) == 9

Now, I know this is valid because Python is very lenient about whitespace (and the parenthenses are really just  "eval '1' first") , but, this is still confusing behavior to someone who does not know about that.

I think the same problem may be possible in the case of statements.

A possible solution is to make sure there is at least some white-space between "alphabetical" operators and statements.

messages: 129933
nosy: abafei
priority: normal
severity: normal
status: open
title: pretending the "not" operator is a function behaves surprisingly
type: behavior
versions: Python 2.6

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list