style question

Hari Sekhon sekhon.hari at googlemail.com
Tue Jun 27 09:59:27 CEST 2006


On 26/06/06, Claudio Grondi <claudio.grondi at freenet.de> wrote:
>
> Scott David Daniels wrote:
> > Claudio Grondi wrote:
> > <<<clever stuff to di indentation>>>
> >
> >> When necessary to skip first line _and_ indentation:
> >>   message = """
> >>   This is line 1
> >>   This is line 2
> >>   This is line 3
> >>   """.replace('\n  ', '\n')[1:] # adjust here '\n  ' to indentation
> >
> >
> > Riffing on this idea:
> >         message = """
> >           This is line 1
> >           This is line 2
> >           This is line 3
> >           """.replace("""
> >           """, '\n')[1:]
>
> This was intended as an excercise for the OP in case he likes that kind
> of solution ...
>
> Claudio
>
> >
> > --Scott David Daniels
> > scott.daniels at acm.org
> --
> http://mail.python.org/mailman/listinfo/python-list
>

I've decided to go with

    message = (
       "This is line1. "
       "This is line2 "
       "This is line3\n")

since I'm declaring many different messages inside various functions I feel
it is important to keep the indentaion and code both aligned properly so the
code looks nice and the output looks nice.

It is easier than doing replace and splicing since I want to keep it as
simple and clean as possible, in true pythonic tradition...

Thanks for the input!

-h
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20060627/44ee3246/attachment.html>


More information about the Python-list mailing list