[New-bugs-announce] [issue39274] Conversion from fractions.Fraction to bool

François Durand report at bugs.python.org
Thu Jan 9 07:43:51 EST 2020


New submission from François Durand <fradurandpub at gmail.com>:

As of now, fractions.Fraction.__bool__ is implemented as: ``return a._numerator != 0``. However, this does not necessary return a bool (which would be desired). In particular, when the numerator is a numpy integer, this returns a numpy bool instead. Another solution would be to implement fractions.Fraction.__bool__ as: ``return bool(numerator)``. What do you think?

This message follows a thread here: https://github.com/numpy/numpy/issues/15277 .

----------
messages: 359673
nosy: francois-durand
priority: normal
severity: normal
status: open
title: Conversion from fractions.Fraction to bool
type: behavior
versions: Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39274>
_______________________________________


More information about the New-bugs-announce mailing list