print string as raw string

Mirko Dziadzka mirko.dziadzka at gmail.com
Tue Feb 17 07:03:16 EST 2009


Mirko Dziadzka <mirko.dziadzka at gmail.com>  wrote:
> Hi all
>
> I'm trying to find a way to output strings in the raw-string format, e.g.
>
> print_as_raw_string(r"\.") should output r"\." instead of "\\."

Ok, lets make a better example:

>>> re_list = {}
>>> re_list['foo'] = r'\..*'
>>> re_list['bar'] = r'.*bar.*'
>>> print re_list
{'foo': '\\..*', 'bar': '.*bar.*'}

I would like to see a:
{'foo': r'\..*', 'bar': '.*bar.*'}


Greetings

    Mirko


-- 
"Never attribute to malice what can be equally explained by stupidity." 



More information about the Python-list mailing list