Title: pretending the "not" operator is a function behaves surprisingly
Type: behavior Stage:
Components: Versions: Python 2.6
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: georg.brandl, hhm, rhettinger
Priority: normal Keywords:

Created on 2011-03-03 05:44 by hhm, last changed 2011-03-03 17:10 by rhettinger. This issue is now closed.

Messages (3)
msg129933 - (view) Author: hhm (hhm) Date: 2011-03-03 05:44
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.
msg129935 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2011-03-03 07:20
I don't think this is wise, or necessary.

I'm not sure why you would treat an operator as callable; the tutorial hopefully doesn't tell you such things.
msg129983 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2011-03-03 17:10
I concur with Georg.
Date User Action Args
2011-03-03 17:10:11rhettingersetnosy: + rhettinger
messages: + msg129983
2011-03-03 07:20:45georg.brandlsetstatus: open -> closed

nosy: + georg.brandl
messages: + msg129935

resolution: rejected
2011-03-03 05:44:40hhmcreate