line continuation for lines ending in "and" or "or"
Russ.Paielli at gmail.com
Thu Jun 5 06:50:19 CEST 2008
On Jun 4, 9:01 pm, Dan Bishop <danb... at yahoo.com> wrote:
> On Jun 4, 10:09 pm, "Russ P." <Russ.Paie... at gmail.com> 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.
> Huh? This doesn't work either:
> >>> x = 2 +
> File "<stdin>", line 1
> x = 2 +
> SyntaxError: invalid syntax
> Implicit line continuation only happens if you have an unmatched '('.
> >>> x = (2 +
> ... 2
> ... )>>> x
Darnit! You're right. I've been reading up on Scala lately, and I
guess I got confused. Well, it wouldn't be a bad idea for Python to do
what I thought it did, *plus* what I said it ought to do.
Scala is a nice language, by the way. Check it out when you get a
chance (http://www.scala-lang.org). I'm thinking about switching over
to it from Python if I can. I just wish it had default arguments and
argument passing by keyword. Now, those are a couple of features that
I really appreciate in Python. Oh, and I wish Scala used "and" and
"or" rather than "&&" and "||". There's another thing Python got right.
More information about the Python-list