Characters Being Misread

Victor Subervi victorsubervi at gmail.com
Tue Jul 15 14:42:16 CEST 2008


Hi;
Forgive multiple posts in one day: online very infrequently
I'm having the darndest time trying to figure out how the character '\b0' is
being read in "('\x0c')"
>>> test = re.search('(?<=\\b)[0]', '\x0c0')
>>> test.group(0)
'0'
>>> type('\x0c')
<type 'str'>
>>> import binascii
>>> binascii.unhexlify('\x0c')
Traceback (most recent call last):
  File "<pyshell#643>", line 1, in <module>
    binascii.unhexlify('\x0c')
TypeError: Odd-length string

What gives here?

Here's another one:
>>> rtf_markup = '\viewkind4\\uc1\\pard\nowidctlpar\\qc\\i\x0c0\x0cs36'
>>> a = []
>>> a.append(re.compile('\\i').match(rtf_markup, 1))
>>> a
[<_sre.SRE_Match object at 0x011802F8>]
>>> a = []
>>> a.append(re.compile('\\qc').match(rtf_markup, 1))
[None]

What's the problem?

TIA,
Victor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080715/c1f7272e/attachment.html>


More information about the Python-list mailing list