Break line across lines (not in '[]' or '{}')?

John Roth johnroth at ameritech.net
Tue Jun 10 16:27:13 EDT 2003


"Robert Oschler" <no_replies at fake_email_address.invalid> wrote in
message news:13rFa.701$Hw.897715 at news2.news.adelphia.net...
> I have a Class with a lot of fields in the __slots__ attribute.  Is
there a
> way to break the line across multiple lines?
>
> Class HasSlots():
>     __slots__ = 'one', 'two', 'three'
>     ...
>
> I'd like to do:
>
> Class HasSlots():
>     __slots__ = 'one', 'two', 'three'
>     ...
>
>     but this produces a syntax error.
>
> thx

I think the slot assignment is a garden variety tuple,
so putting parenthesis around it should do what you want.

  __slots__ = ('one', 'two',
           'three')

This is a technical detail about tuples: it's the comma that
is significant in defining a tuple, not the parenthesis. Except in
two cases, the parens are simply syntactic sugar. (They make
the tuple into an expression.)

If there's some reason you don't want to use parenthesis,
use a backslash before the newline at the end of the line.

John Roth
>
> --
>
>
>
> Robert Oschler,
> Android Technologies, Inc.
> http://www.androidtechnologies.com
> - The home of Off-Book! (tm)
> The scene memorization tool for Actors and Actresses!
>
>
>






More information about the Python-list mailing list