Re: python strings

Rickard Westman (ricwe@ida.liu.se)
Fri, 22 Apr 1994 21:22:02 GMT

Thus quoth Guido.van.Rossum@cwi.nl:

>For the same reason I don't believe that having some kind of
>indentation stripping inside string literals is important enough to
>warrant the extra machinery, documentation, confusion etc.

As an admirer of Python's clean and elegant syntax, I think it would
be sinful to add syntactical constructs which cannot be properly
indented. :-)

Contrast this...

-------------------------------------------
if event==1:
print """
Mischievous Glac-elves broke into your
storage shed and stole half your food!
"""
else:
print """
Your MULE was bitten by a moose rat!
Repairs cost $%d.
""" % rcost
-------------------------------------------

...or perhaps this (my personal favorite):

-------------------------------------------
if event==1:
print quote:
Mischievous Glac-elves broke into your
storage shed and stole half your food!
else:
print quote:
Your MULE was bitten by a moose rat!
Repairs cost $%d. \
% rcost
-------------------------------------------

to this...

-------------------------------------------
if event==1:
print """
Mischievous Glac-elves broke into your
storage shed and stole half your food!
Repairs cost $%d.
"""
else:
print """
Your MULE was bitten by a moose rat!
Repairs cost $%d.
""" % rcost
-------------------------------------------

What a mess the latter is!

>If you insist that your string literals be properly indented, you
>can still use literal concatenation.

I think the language should encourage proper indentation, and never
disallow it. This is especially important for languages like
Python, where indentation is semantically significant. The
suggested syntax would disallow proper indentation, and encourage
sloppy indentation.

(As for whitespace in the beginning of lines, the "leading
backslash idea" (by Donald Beaudry) is nice, even though handling
this case seems less important, IMHO...)

--
Rickard Westman <ricwe@ida.liu.se>  |  "I think not."
Programming Environments Laboratory |
University of Linkvping, Sweden     |        - Descartes' last words?
------------------------------------+------------------------------------