Re: requestion regarding regular expression

2006-04-15 Thread Kelie
Thanks to both of you, Kent and Scott. -- http://mail.python.org/mailman/listinfo/python-list

Re: requestion regarding regular expression

2006-04-14 Thread BartlebyScrivener
This is very helpful. I wasn't the OP. I'm just learning, but I'm on the verge of making my own file searching scripts. This will be a huge help. Thanks for posting, and especially thanks for the comments in the code. Big help! rick -- http://mail.python.org/mailman/listinfo/python-list

Re: requestion regarding regular expression

2006-04-14 Thread Scott David Daniels
BartlebyScrivener wrote: > That's it. Thank you! Very instructive. > > Final: > > path = "d:/emacs files/emacsinit.txt" > lines = open(path).readlines() > # next two lines all on one > starts = [i for i, line in enumerate(lines) if > line.startswith('(defun')] > for i, start in enumerate(starts):

Re: requestion regarding regular expression

2006-04-14 Thread BartlebyScrivener
That's it. Thank you! Very instructive. Final: path = "d:/emacs files/emacsinit.txt" lines = open(path).readlines() # next two lines all on one starts = [i for i, line in enumerate(lines) if line.startswith('(defun')] for i, start in enumerate(starts): while start > 0 and lines[start-1].start

Re: requestion regarding regular expression

2006-04-14 Thread Kent Johnson
BartlebyScrivener wrote: > Kent, > > Running > > path = "d:/emacs files/emacsinit.txt" > lines = open(path).readlines() > # my defun lines are lowercase, > # next two lines are all on one > starts = [i for i, line in enumerate(lines) if > line.startswith('(defun')] > for i, start in starts: >

Re: requestion regarding regular expression

2006-04-14 Thread Felipe Almeida Lessa
Em Sex, 2006-04-14 às 07:47 -0700, BartlebyScrivener escreveu: > starts = [i for i, line in enumerate(lines) if > line.startswith('(defun')] This line makes a list of integers. enumerate gives you a generator that yields tuples consisting of (integer, object), and by "i for i, line" you unpack the

Re: requestion regarding regular expression

2006-04-14 Thread BartlebyScrivener
Kent, Running path = "d:/emacs files/emacsinit.txt" lines = open(path).readlines() # my defun lines are lowercase, # next two lines are all on one starts = [i for i, line in enumerate(lines) if line.startswith('(defun')] for i, start in starts: while start > 0 and lines[start-1].startswith(';

Re: requestion regarding regular expression

2006-04-14 Thread Kent Johnson
Kelie wrote: > Hello, > > I'm trying to analyze some autolisp code with python. In the file to > be analyzed there are many functions. Each function begins with a > "defun" statement. And before that, there may or may not have comment > line(s), which begins with ";". My goal is to export each

requestion regarding regular expression

2006-04-14 Thread Kelie
Hello, I'm trying to analyze some autolisp code with python. In the file to be analyzed there are many functions. Each function begins with a "defun" statement. And before that, there may or may not have comment line(s), which begins with ";". My goal is to export each function into separate f