[PyKDE] More significant repr for Qt data types

Giovanni Bajo rasky at develer.com
Thu Mar 9 11:06:57 GMT 2006


Hello,

with SIP 4.4 coming out and the advanced duck typing between QString and Python
strings, I wonder if it's time for QString (and maybe other Qt data types) to
get more meaningful repr strings. For instance:

>>> from qt import *
>>> a = QString("foo")
>>> file(a)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
IOError: [Errno 2] No such file or directory: <qt.QString object at 0x029693D8>

Pretty useless error, isn't it? I'd suggest a repr string along the lines of:

>>> a
QString(u"foo")

So that eval(repr(a)) works.

I can think of several classes which could really benefit from more informative
repr strings: QPoint, QRect, QSize...

Giovanni Bajo




More information about the PyQt mailing list