Are line continuations needed?

Mark Jackson mjackson at alumni.caltech.edu
Wed Apr 7 10:50:37 EDT 2004


Derek Thomson <derek at hiredgoons.org> writes:
> 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
> =====

This ought to work:

class ParticleDistributionBehaviorServer(
           Microphysics__POA.ParticleDistributionBehavior):

-- 
Mark Jackson - http://www.alumni.caltech.edu/~mjackson
	Hate to interrupt with a spelling flame, but it's "Cheney,"
	not "Chaney."  It may only be one letter, but it's 998 faces.
					- Mike Peterson





More information about the Python-list mailing list