Thanks to both of you, Kent and Scott.
--
http://mail.python.org/mailman/listinfo/python-list
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
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):
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
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:
>
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
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(';
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
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