Multiline strings and indentation

David Bolen db3l at fitlinxx.com
Mon Jul 17 21:44:55 EDT 2000


"donotspam-jen at personic.com" <dnotspam-jen at personic.com> writes:

> But in both cases you have to put in extra quotes and explict newline
> characters (unless you don't care where the text wraps).

Well, you sort of have to explicitly handle the newlines with multi-line
strings as well, since they are only going to wrap where you actually
wrap them.

>                                                          Multi-line strings
> save a bit of typing, and are a bit easier to reformat when editing. So I
> guess this means I have to choose between weird indentation (multi-line
> strings) or typing more characters?

Either that or see what is leading you to using such long,
multiple-line strings (needs line breaks within string) directly
within the code and see if you might not be better suited with some
sort of data structure to access those strings.

I don't know what the strings are for, but if they are messages, or
prompts, or other user I/O, perhaps installing them in a dictionary or
some other structure within your code would permit you to just
retrieve the appropriate string later without needing the inline
multi-line strings.  That would also permit later extraction for
separate message handling, internationalization, etc.. should the need
ever arise.  It would also cluster these long messages in a single
place in your code for maintenance.

Just a thought - it might not be relevant in your particular
application.  For myself I tend to find most strings relatively small
(and the occasional full line string that is longer than my source
line I just let Python do with the automatic string concatentation of
two adjacent strings) within the source itself, longer strings
tending to be related to some other structure within the code.

--
-- David
-- 
/-----------------------------------------------------------------------\
 \               David Bolen            \   E-mail: db3l at fitlinxx.com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \
\-----------------------------------------------------------------------/



More information about the Python-list mailing list