what is wrong with that r"\"

samwyse samwyse at gmail.com
Sun Jul 8 13:25:11 CEST 2007

On Jul 4, 7:15 am, Matthieu TC <matthie... at yahoo.com> wrote:
> May I suggest giving the possibility to use any delimiter for a raw string?  just like in Vi or ruby.
> Vi:
>  %s_a_b_g  is valid and so is  %s/a/b/g
> Ruby:
>  %q{dj'\ks'a\'"}   or %q-dj'\ks'a\'"-
> So as long as your regex does not use all the valid characters, readability is maintained.

first, you'll need a way to flag that something is an arbitrarily
quoted string; 'r' is taken, so let's use 'q'.  next, you need to
distinguish strings from variables, perhaps by adding a flag to all
variables; $ should do nicely and has some historical precident.  once
you've done all that, you can write something like this:
  $q = q|this so-called "string" doesn't use conventional quotes|

congratulations!  you've just invented perl!

More information about the Python-list mailing list