[PyQt] Repr for "value" objects
Andreas Pakulat
apaku at gmx.de
Mon Dec 17 15:25:05 GMT 2007
On 17.12.07 14:48:48, Phil Thompson wrote:
> On Monday 17 December 2007, Giovanni Bajo wrote:
> > Hi,
> >
> > there are many classes in PyQt which would benefit from a custom
> > __repr__ method to show their contents. For instance, I'm getting tired
> > of having to write:
> >
> > def mousePressEvent(self, e):
> > print e.pos().x(), e.pos().y()
> >
> > instead of:
> >
> > def mousePressEvent(self, e):
> > print e.pos()
> >
> > just because I otherwise get "<PyQt4.QtCore.QPoint object at 0x298EA468>".
> >
> > Are there any plans to add this to PyQt?
>
> It's on the TODO list.
>
> > I'm happy to provide a list of
> > objects that might have a custom repr method, and even to actually write
> > the code (if Phil explains me how he prefers this to be submitted --
> > given metasip).
>
> A list would help. The code would help more (just a patch against the source
> would be fine).
Wouldn't it be possible to utilize the already-existing operator<< for
QTextStream for this? I mean Qt itself can already "pretty print" almost
all their basic datatypes, so it seems like a good idea to use that code
to produce some string for __repr__.
BTW: Does PyQt allow to use qDebug() as in C++? (qDebug() << foo <<
"somestring")
Andreas
--
You have no real enemies.
More information about the PyQt
mailing list