line continuation for lines ending in "and" or "or"

Tim Roberts timr at
Thu Jun 5 09:17:31 CEST 2008

Dan Bishop <danb_83 at> wrote:
>On Jun 4, 10:09 pm, "Russ P." <Russ.Paie... at> wrote:
>> I've always appreciated Python's lack of requirement for a semi-colon
>> at the end of each line. I also appreciate its rules for automatic
>> line continuation. If a statement ends with a "+", for example, Python
>> recognizes that the statement obviously must continue.
>> I've noticed, however, that the same rule does not apply when a line
>> ends with "and," "or," or "not." Yes, it's a minor point, but
>> shouldn't the same rule apply?
>> Seems like it would be easy to add.
>Implicit line continuation only happens if you have an unmatched '('.
>>>> x = (2 +
>... 2
>... )
>>>> x

... or an unmatched [ or an unmatched {.
Tim Roberts, timr at
Providenza & Boekelheide, Inc.

More information about the Python-list mailing list