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

2006-04-09 Thread Leif K-Brooks
Sandra-24 wrote: > I'm not sure how complex this is, I've been brainstorming a little, and > I've come up with: from tokenize import generate_tokens, NL, NEWLINE from cStringIO import StringIO def code_lines(source): """Takes Python source code (as either a string or file-like object) a

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

2006-04-09 Thread Hans Georg Krauthaeuser
Sandra-24 wrote: > 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: >

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

2006-04-08 Thread Michael Spencer
Sandra-24 wrote: > No it's not an academic excercise, but your right, the situation is > more complex than I originally thought. I've got a minor bug in my > template code, but it'd cause more trouble to fix than to leave in for > the moment. > > Thanks for your input! > -Sandra > Take a look at

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

2006-04-08 Thread Sandra-24
No it's not an academic excercise, but your right, the situation is more complex than I originally thought. I've got a minor bug in my template code, but it'd cause more trouble to fix than to leave in for the moment. Thanks for your input! -Sandra -- http://mail.python.org/mailman/listinfo/pyth

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

2006-04-08 Thread Dan Sommers
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 th

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

2006-04-08 Thread Sandra-24
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 ]