On 6 Oct 2006 21:07:43 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> I want comment returned in an array and instr_number returned in an
> array.
Let me see if I understand what you want: if there is a line that
starts with instr (best tested with line.startswith('instr') :)), you
want the number and the commen afterwards. I used regexes for this
purpose. In your case:
import re
<snip>
if line.startswith('instr'):
p = re.compile(r'(\d+)\s+;(.*)$')
m = p.search(line)
return (m.group(1), m.group(2))
I returned a tuple of course; you may wish to change that.
BTW, thank you -- I just learned how to use re's in Python.
--
http://mail.python.org/mailman/listinfo/python-list