Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pretending the "not" operator is a function behaves surprisingly #55590

Closed
hhm mannequin opened this issue Mar 3, 2011 · 3 comments
Closed

pretending the "not" operator is a function behaves surprisingly #55590

hhm mannequin opened this issue Mar 3, 2011 · 3 comments
Labels
type-bug An unexpected behavior, bug, or error

Comments

@hhm
Copy link
Mannequin

hhm mannequin commented Mar 3, 2011

BPO 11381
Nosy @birkenfeld, @rhettinger

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2011-03-03.07:20:45.888>
created_at = <Date 2011-03-03.05:44:40.307>
labels = ['type-bug']
title = 'pretending the "not" operator is a function behaves surprisingly'
updated_at = <Date 2011-03-03.17:10:11.202>
user = 'https://bugs.python.org/hhm'

bugs.python.org fields:

activity = <Date 2011-03-03.17:10:11.202>
actor = 'rhettinger'
assignee = 'none'
closed = True
closed_date = <Date 2011-03-03.07:20:45.888>
closer = 'georg.brandl'
components = []
creation = <Date 2011-03-03.05:44:40.307>
creator = 'hhm'
dependencies = []
files = []
hgrepos = []
issue_num = 11381
keywords = []
message_count = 3.0
messages = ['129933', '129935', '129983']
nosy_count = 3.0
nosy_names = ['georg.brandl', 'rhettinger', 'hhm']
pr_nums = []
priority = 'normal'
resolution = 'rejected'
stage = None
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue11381'
versions = ['Python 2.6']

@hhm
Copy link
Mannequin Author

hhm mannequin commented Mar 3, 2011

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:
not(True)

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

>>> not(1) == 9
True

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.

@hhm hhm mannequin added the type-bug An unexpected behavior, bug, or error label Mar 3, 2011
@birkenfeld
Copy link
Member

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.

@rhettinger
Copy link
Contributor

I concur with Georg.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants