[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: Using QDebug for __repr__?
From: Florian Bruhin <me () the-compiler ! org>
Date: 2022-05-02 18:45:33
Message-ID: 20220502184533.73wndptnsmumfcxn () aragog
[Download RAW message or body]
Hi,
PyQt seems to have hand-written __repr__ implementations for a handful
of types:
QtGui/qgenericmatrix.sip
QtGui/qvectornd.sip
QtGui/qmatrix4x4.sip
QtGui/qquaternion.sip
QtCore/qdatetime.sip
QtCore/qregularexpression.sip
QtCore/qline.sip
QtCore/qsize.sip
QtCore/qpoint.sip
QtCore/qbytearray.sip
QtCore/quuid.sip
QtCore/qrect.sip
QtCore/qurl.sip
PySide takes a different approach there, by using QDebug writing to a
QBuffer and then returning that:
https://doc.qt.io/qt-6/qdebug.html
This often results in it having much more descriptive __repr__'s, e.g.:
>>> from PySide6.QtGui import QAction, QGuiApplication
>>> app = QGuiApplication([])
>>> QAction()
<PySide6.QtGui.QAction(0x55c428114b50 text="" menuRole=TextHeuristicRole \
enabled=true visible=true) at 0x7f09becb1a00>
vs.
<PyQt6.QtGui.QAction object at 0x7f09beccda20>
Perhaps PyQt6 could do something similar too?
Thanks,
Florian
--
me@the-compiler.org | https://www.qutebrowser.org
https://bruhin.software/ | https://github.com/sponsors/The-Compiler/
GPG: 916E B0C8 FD55 A072 | https://the-compiler.org/pubkey.asc
I love long mails! | https://email.is-not-s.ms/
["signature.asc" (application/pgp-signature)]
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic