En Thu, 21 May 2009 08:23:36 -0300, Srijayanth Sridhar
<srijaya...@gmail.com> escribió:
I am wondering if it is possible to have hexadecimal strings in a ini
file
and have configobj parse it correctly.
for eg:
moonw...@trantor:~/python/config$ cat foo
foo="\x96\x97"
.
.
.
a=ConfigObj("foo")
a
ConfigObj({'foo': '\\x96\\x97'})
a['foo']
'\\x96\\x97'
Use the "string-escape" codec to decode that:
py> x = '\\x96\\x97'
py> x.decode("string-escape")
'\x96\x97'
You can decode more-or-less automatically the whole config file, using the
walk method. See
http://www.voidspace.org.uk/python/configobj.html#walking-a-section (the
example covers exactly this use case)
--
Gabriel Genellina
--
http://mail.python.org/mailman/listinfo/python-list