Diez B. Roggisch <de...@nospam.web.de> wrote: >> 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 "\\." >> >> Is there a better way than writing your own print function? Some magic >> encoding? > > There is no need to do this. Rawstrings are only different wrt to their > parsing, the resulting string is the exact same.
I know. Maybe a little bit more eplaination from my site. I'm going to generate python source which contains lot of regex-strings and I want this code to be easy readable and editable. In fact, editing these regexes is the main reason for exporting them. So I would prefer the more compact and readable raw-string notation instead of the smantic equivalent string notation. So I'm going to write these couple of lines to convert a string in this raw-string format. Greetings Mirko -- "In C we had to code our own bugs. In C++ we can inherit them." -- http://mail.python.org/mailman/listinfo/python-list