[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] Comparing QString with QChar
From:       Phil Thompson <phil () riverbankcomputing ! com>
Date:       2008-06-27 17:51:59
Message-ID: 21ea48789334c9fa368aa235e979691c () localhost
[Download RAW message or body]

On Fri, 27 Jun 2008 16:57:27 +0100, Mark Summerfield <mark@qtrac.eu> wrote:
> On 2008-06-27, Phil Thompson wrote:
>> On Fri, 27 Jun 2008 09:38:04 +0100, Mark Summerfield <mark@qtrac.eu>
> wrote:
>> > Hi,
>> >
>> > I got caught by this today:
>> >     >>> from PyQt4.QtCore import *
>> >     >>> s = QString("X")
>> >     >>> c = QChar("X")
>> >     >>> s[0] == c
>> >
>> >     False
>> >
>> >     >>> s[0] == QString(c)
>> >
>> >     True
>> >
>> > In C++/Qt if you do the s[0] == c comparison it will return true
> because
>> > operator[] returns a const QChar &, but in PyQt4 s[0] is still a
>> > QString---which makes sense because in Python a char is just a str of
>> > length 1, but maybe this particular case could be handled more
>> > intuitively?
>>
>> By allowing a QChar whenever a QString is expected?
> 
> Seems reasonable given that Python doesn't make the char/str
> distinction.

Done in tonight's snapshot.

> Of course what would be really nice is to say something like:
> 
>     from __future__ import native_str
> 
> to help get rid of QString usage. (I _like_ QString, but I just find the
> Qt Jambi solution so much better;-)

Phil

_______________________________________________
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