[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: [PyQt] unicode(QChar) produces unexpected result?
From: David Cortesi <davecortesi () gmail ! com>
Date: 2012-08-09 20:15:10
Message-ID: CALyzANvhaW1-cZkCtJSMmWUUotw+R2yMHNqCc3rSZ13vriBYfQ () mail ! gmail ! com
[Download RAW message or body]
To get a python string copy of the contents of a QString object, I have
been using unicode(some_qstring) .
>>> qs = QString(u'BAZ')
>>> len(unicode(qs))
3
So I was surprised when I did the analogous thing to get a
python string copy of the contents of a QChar.
>>> qc = QChar(u'Z')
>>> len(unicode(qc))
24
>>> unicode(qc)
u'PyQt4.QtCore.QChar(0x5a)'
It appears to produce the _repr_ value. Is this intended?
Investigating I find that QChar has a unicode() method which
assistant says returns a ushort.
>>> qc.unicode()
90L
note the L suffix - is this an artifact of the cpp interface code or what?
In the end this is the only way I see to make a QChar into a python string:
>>> unicode(QString(qc))
u'Z'
Thoughts?
_______________________________________________
PyQt mailing list PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic