Are line continuations needed?

John Roth newsgroups at jhrothjr.com
Wed Apr 7 10:33:30 EDT 2004


"Derek Thomson" <derek at hiredgoons.org> wrote in message
news:40740f99 at duster.adelaide.on.net...
> Russell Wallace wrote:
> > Hi all,
> >
> > Python lets you continue a single logical line across more than one
> > physical line, either by putting a \ at the end or letting it happen
> > automatically with an incomplete infix operator.
> >
> > I'm wondering how often is this feature needed? Would there be any
> > problems if it weren't part of the language?
> >
>
> I just needed to use this a few minutes ago, in a class declaration ...
>
> class ParticleDistributionBehaviorServer \
>            (Microphysics__POA.ParticleDistributionBehavior):
>
> I had to split the line to fit within 80 columns, and without the '\'
> character I get the following error:
>
> =====
> $ python scoping_server.py --POA
>    File "scoping_server.py", line 8
>      class ParticleDistributionBehaviorServer
>                                              ^
> SyntaxError: invalid syntax
> =====
>
> So the fact that you don't need it in the case of incomplete expressions
> eliminates *most* of the need for it, but there are still a few cases
> where it is required.

Technically, you could have split it at the period, but that
might be even worse in terms of readability.

BTW - why did it have to fit in 80 columns?

John Roth
>
> Regards,
> Derek.





More information about the Python-list mailing list