How to determine if a line of python code is a continuation of the line above it

Sandra-24 sandravandale at yahoo.com
Sat Apr 8 14:24:04 EDT 2006


I'm not sure how complex this is, I've been brainstorming a little, and
I've come up with:

If the previous line ended with a comma or a \ (before an optional
comment)

That's easy to cover with a regex

But that doesn't cover everything, because this is legal:

l = [
     1,
     2,
     3
     ]

and with dictionaries and tuples as well.

Not sure how I would check for that programmatically yet.

Is there any others I'm missing?

Thanks,
-Sandra




More information about the Python-list mailing list