The other day I was writing a script to extract data from a file from the line where a text is found to the end of the file. The same functionality is this sed script: '1,/regexp/'d I couldn't put my head to work around this and came up with a solution using list slicing. But how can I do that? I was experimenting with a simple list and I came up with this. I wonder if I shouldn't you a "while" statement, but how?
a = ['m', 'a', 'r', 'i', 'g', 'o', 'l', 'd'] b = True for letter in a: if letter != 'i' and b: continue elif letter == 'i': b = False else: print letter Ok. This works, but I wonder if I shouldn't you a "while" statement, but how? Of course this solution is simpler: extracted = a[a.index("i")+1:] But I didn't want to build a list in memory with "readlines()" in the case of a file. Thanks for your guidance, Eduardo _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor