[Tutor] SQLite3 DB Field Alphabetizing

Joel Goldstick joel.goldstick at gmail.com
Wed Oct 13 14:17:29 CEST 2010


On Wed, Oct 13, 2010 at 4:01 AM, Alan Gauld <alan.gauld at btinternet.com>wrote:

> "David Hutto" <smokefloat at gmail.com> wrote
>
>  Below is the output before converting:
>>
>> [(u'.hjvkjgfkj/bdgfkjbg', u''), (u'bbbbbbbbbbbbuuzzzzzzzzz', u'Pie
>> Chart'), (u'jgkgyckghc', u''), (u'kfhhv ', u''), (u'khfhf', u''),
>> (u'test', u''), (u'test10', u''), (u'test2', u'Dashed/Dotted'),
>> (u'test3', u'Pie Chart'), (u'test346w43', u''), (u'test4', u'Scatter
>> Plot'), (u'test5', u''), (u'test6', u''), (u'test7', u''),
>> (u'test7uyuy', u''), (u'test8', u''), (u'test9', u''), (u'testgraph',
>> u''), (u'u;s;juf;sfkh', u''), (u'zzrerhshhjrs', u'')]
>>
>
> And there is the answer to your question.
> The string that you thought started with ; actually starts with a 'u'
> But you strip the 'u;' off that entry so it appears to be badly ordered.
>
> So the next question is why do you strip the 'u' off?
>
> I suspect the answer to that also lies here.
> I suspect you think you need to strip all the 'u's from the front of
> these results but in fact those 'u's lie outside the string, they
> are a part of Python's representation of a unicode string,
> not a part of the string.
>
> So if you remove the call to strip() your code will return
> the result you expected.
>
>
>
> --
> Alan Gauld
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
>
>
> Not to belabor the point too much, I plucked one of your strings out and
printed it.  Looking at your data, all those u' prefixes you thought you
were removing were (in a sense) never really there!  The only u you removed
was the one near the end that was followed with a semicolon.


print u'zzrerhshhjrs'
zzrerhshhjrs

-- 
Joel Goldstick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20101013/cd39fa27/attachment.html>


More information about the Tutor mailing list