[Tutor] quoting and escaping
John Fouhy
john at fouhy.net
Wed Jan 14 01:12:10 CET 2009
2009/1/14 Jon Crump <jjcrump at myuw.net>:
>>>> b = """{"aKey" : "a value with \"literal quotes\" in it"}"""
>>>> eval(b)
>
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "<string>", line 1
> {"aKey" : "a value with "literal quotes" in it"}
> ^
> SyntaxError: invalid syntax
Is it an option to just do:
>>> b = """{'aKey':'a value with "literal quotes" in it'}"""
>>> eval(b)
{'aKey': 'a value with "literal quotes" in it'}
?
(or, heck, get rid of eval.. do you really need it?)
--
John.
More information about the Tutor
mailing list