[PyQt] Floats accepted for C++ ints?
Hans-Peter Jansen
hpj at urpla.net
Wed Jul 6 06:56:19 BST 2016
On Mittwoch, 6. Juli 2016 00:07:30 Florian Bruhin wrote:
> * Phil Thompson <phil at riverbankcomputing.com> [2016-07-05 22:18:16 +0100]:
> > On 5 Jul 2016, at 9:51 pm, Florian Bruhin <me at the-compiler.org> wrote:
> > >
> > > float is not a subclass of int (i.e. isinstance(1.5, int) == False),
> > > which is why this not raising a TypeError confuses me.
> >
> > It's how PyLong_AsLong() works...
> >
> > https://docs.python.org/3/c-api/long.html#c.PyLong_AsLong
>
> Fair enough - I guess you could call PyLong_Check() on it first
> ("Return true if its argument is a PyLongObject or a subtype of
> PyLongObject"), but it might also be too late to do that now?
And these are the historical reasons I was talking about, given the ubiquitous
usages of QRects.
If QRects are too unprecise, QRectF.toRect() provide a better rounding
behaviour for float coordinates.
Pete
More information about the PyQt
mailing list