[PyKDE] Type-errors and such...

Phil Thompson phil at river-bank.demon.co.uk
Tue Dec 12 18:19:23 GMT 2000

Jesper Eskilson wrote:
> Hi!
> I've used PyQt for a couple of months now, and most problems I've had with
> PyQt boils down to one thing: type conversions.
> - The error message "TypeError: Invalid argument types to..." is extremely
>   annoying and almost completely useless since it gives no hint about (1)
>   *what* argument is the culprit, (2) what type was expected, and (3) what
>   type was actually found.

I've just committed changes to SIP and PyQt to improve this. It now
tells you which argument it didn't like - but it doesn't go as far as
telling you what the valid possibilities are.

> - I've found no documentation whatsoever about *how* PyQt (or sip?)
>   converts C++ arguments to Python arguments. Yes, there is the PyQt
>   documentation on what API calls differ substantially, but what I'm
>   missing is some documentation guiding a new user as to how the
>   Qt-documentations should be read when trying to figure out how to call a
>   C++ method in Qt from Python. I encountered this problem when trying to
>   create a QPointArray object. The PyQt-documentation said "fully
>   implemented", and the C++ documentation said that the QPointArray
>   constructor wanted a QPoint * as argument. Since there was no
>   documentation on what this should be in Python, I guessed and passed a
>   list of QPoint objects.
>         list[0] = QPoint(0,0)
>         list[1] = QPoint(1,0)
>         ...
>         array = QPointArray(list)
>   this did not work. All I got was the useless TypeError. I had to ask Phil
>   about what to do, and he told me that the QPointArray constructor wants a
>   list of integers: [x1,y1,x2,y2,x3,y3,...]. Quite an ok solution, but not
>   very intuitive.

This will be announced properly in the next couple of weeks, but there
is going to be a commercial version of PyQt. PyQt will stay the same,
but the commercial version will have extra things. One of the extras is
Python specific documentation - class descriptions will only include
those parts of Qt actually implemented and arguments will be described
in Python types not C++ types.


More information about the PyQt mailing list