Python -Vs- Ruby: A regexp match to the death!

MRAB python at
Mon Aug 9 03:14:18 CEST 2010

rantingrick wrote:
> Hello folks,
> ---------------------
>  Strings
> ---------------------
> Single line strings are exactly the same in both languages except in
> Ruby double quoted strings are backslash interpreted and single quote
> strings are basically raw. Except Ruby introduces more cruft (as
> usual) in the form of what i call "lazy man" stings....
>>>> a = %w{ one two three}
> ["one", "two", "three"]
>>>> s = %{one two three}
> one two three
>>>> repat = %r{one two three}
> /one two three/
> ... only good for hand coding!
 From Perl.

> ----------------------
>  Multi Line Strings
> ----------------------
> Ha. Ruby does not really have multi line strings. Ruby has what they
> call a "Here Doc". Besides picking the most boneheaded name for such
> an object they also introduced and even more boneheaded syntax. To
> define a "Here Doc" (god i hate that name!) you start with double
> greater than ">>" and immediately follow with an identifier token of
> you choice (it can be anything your dirty little mind can come up
> with.
> this is the body
> of a
> here doc. Why the
> hell did they not just
> use triple quotes like Python did.
> Now i will need to remember some token to know where'
> i stopped
> As you can see it is another example of tacked on functionality that
> was not carefully considered before hand. Anyway here are the
> regexp's...
>   Python: r'""".*?"""'
>   Python: r"'''.*?'''"
>     Ruby: r'<<(\w+).*?(\1)'
Also from Perl.

I don't know what the point of your post was. We already know that we
prefer Python; that's why we're here! :-)

And anyway, being nasty about other languages feels unPythonic to me...

More information about the Python-list mailing list