Hei,

On 2006-10-30 08:25:41 +0100, thebjorn wrote:
>   def unfk(s):
>       return eval(repr(s)[1:]).decode('utf-8')
> 
> i.e. chopping off the u in the repr of a unicode string, and relying on
> eval to interpret the \xHH sequences.
> 
> Is there a less hack'ish way to do this?

Slightly lack hackish:

return ''.join(chr(ord(c)) for c in s)

Gerrit.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to