On 8 Apr 2006 11:24:04 -0700, "Sandra-24" <[EMAIL PROTECTED]> wrote:
> I'm not sure how complex this is, I've been brainstorming a little, and > I've come up with: ["This" meaning how to determine if a line of python code is a continuation of the line above it.] > If the previous line ended with a comma or a \ (before an optional > comment) A line ending with a comma does *not* indicate a single statement spread out over two lines: a = 1, print a, a = [ ] None of those lines is a continuation of the line above it. > That's easy to cover with a regex > But that doesn't cover everything ... I think you'll end up having to parse the code in its entirety to do this correctly. Consider triple quoted strings and multiple uses of parenthesis, both of which can be nested arbitrarily, including inside each other, and arbitrarily nested delimeters are beyond the ability of regexen. Is this merely an academic exercise, or is there a larger purpose for wanting this information? Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> "I wish people would die in alphabetical order." -- My wife, the genealogist -- http://mail.python.org/mailman/listinfo/python-list