[Tutor] Continuation of long lines of string characters

brian arb brianjamesarb at gmail.com
Wed May 1 04:28:07 CEST 2013


I really like breaking my long strings like...

Take this...
my_very_long_string = "I have been looking through PEP 8--Style Guide for
Python Code. It recommends a maximum line length of 79 characters. What is
the preferred way to continue on another line or lines really long print
functions of string literals (Python 3)? The only thing that immediately
occurs to me is to break up the string literal into multiple parts
separated by + and break after the + . This seems to use Python's built-in
line continuation of anything between parens. Is this the preferred way to
do this?"

And rewrite it like this...
my_very_long_string = ('I have been looking through PEP 8--Style Guide for
Python Code.'
                       'It recommends a maximum line length of 79
characters. What is the'
                       'preferred way to continue on another line or lines
really long print'
                       'functions of string literals (Python 3)? The only
thing that'
                       'immediately occurs to me is to break up the string
literal into'
                       'multiple parts separated by + and break after the +
. This seems to'
                       'use Python\'s built-in line continuation of
anything between parens. Is'
                       'this the preferred way to do this?')

On Tue, Apr 30, 2013 at 10:12 PM, boB Stepp <robertvstepp at gmail.com> wrote:

> I have been looking through PEP 8--Style Guide for Python Code. It
> recommends a maximum line length of 79 characters. What is the
> preferred way to continue on another line or lines really long print
> functions of string literals (Python 3)? The only thing that
> immediately occurs to me is to break up the string literal into
> multiple parts separated by + and break after the + . This seems to
> use Python's built-in line continuation of anything between parens. Is
> this the preferred way to do this?
>
> Thanks!
> boB
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130430/ff7d8c7e/attachment-0001.html>


More information about the Tutor mailing list