How do I display unicode value stored in a string variable using ord()

Paul Rubin no.email at nospam.invalid
Sat Aug 18 22:35:44 EDT 2012


Chris Angelico <rosuav at gmail.com> writes:
>>>> "asdfqwer"[4:]
> 'qwer'
>
> That's a not uncommon operation when parsing strings or manipulating
> data. You'd need to completely rework your algorithms to maintain a
> position somewhere.

Scanning 4 characters (or a few dozen, say) to peel off a token in
parsing a UTF-8 string is no big deal.  It gets more expensive if you
want to index far more deeply into the string.  I'm asking how often
that is done in real code.  Obviously one can concoct hypothetical
examples that would suffer.



More information about the Python-list mailing list