[issue37818] Behaviors of binary bitwise operators contradicting documentation

2019-08-10 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

bools are integers, specifically they are a subclass of int:

py> isinstance(True, int)
True
py> issubclass(bool, int)
True

so the behaviour is correct.

--
nosy: +steven.daprano
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37818] Behaviors of binary bitwise operators contradicting documentation

2019-08-10 Thread John Rogers


New submission from John Rogers :

In Python Language Reference (version 3.7), section 6.9 it states that the 
arguments of binary bitwise operators must be integers. However, the following 
expressions work without error:

True & False
False | True
True ^ True

Each produces a boolean result (not integer) (False, True, False, 
respectively). Also I find that mixing booleans and integers does work too, 
though this time it produces integers.

One can easily test it on Python home page's console window. I also tested it 
on my Linux box running version 3.5.3. So it appears that it has been 
overlooked for quite some time!

As an aside: I do assume that boolean values are *distinct* from integers. If 
they are not, then my apologies!

--
assignee: docs@python
components: Documentation
messages: 349372
nosy: The Blue Wizard, docs@python
priority: normal
severity: normal
status: open
title: Behaviors of binary bitwise operators contradicting documentation
type: behavior
versions: Python 3.5, Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com