My first Python program

Ben Finney ben+python at benfinney.id.au
Wed Oct 13 20:23:18 EDT 2010


Seebs <usenet-nospam at seebs.net> writes:

> On 2010-10-13, Ben Finney <ben+python at benfinney.id.au> wrote:
> > Python borrows from C in that consecutive literal strings are
> > concatenated in the bytecode::
> >
> >     stderr.write(
> >         "WARNING:"
> >         " Pants on fire\n")
>
> Hmm. So I just indent stuff inside the ()s or whatever? I can work
> with that.

Yes. More generally, within any “parenthesising” operators, like parens,
brackets, or braces. Anything which allows Python's parser to read the
next line as a continuation.

You'll often find code written in a different style:

    long_line_to_demonstrate_my_point.write("WARNING:"
                                            " Pants on fire\n")

but I find that silly and unwieldy, especially when the early parts of
the first line change length.

-- 
 \        “Of course, everybody says they're for peace. Hitler was for |
  `\      peace. Everybody is for peace. The question is: what kind of |
_o__)                                peace?” —Noam Chomsky, 1984-05-14 |
Ben Finney



More information about the Python-list mailing list