[Tutor] Reading text until a certain point
stefan at lsd.co.za
Fri Jul 24 17:39:44 CEST 2009
It seems like this keeps coming up (for me anyways), and i'm never sure how
to do it. I'm very new to programming...
I have a file that has text in a certain format. Lets assume
The format is predictable. I understand for non predictable text, you would
have to use pyparser or the like to build a match.
For predictable format, I am never sure how to handle this. I normally use
for line in file:
The problem being i dont really do something per line? I would like to say
something like, for line until the next 'name', make that 1 element.
So i would like to then have a list or dict (this probably makes sense for a
dict) with that group. I would then probably split it into various elements.
So essentially im asking, how do i say the for line until next 'match'.
Would this be something for the re module? Or is there an inbuilt core way?
I hope this makes sense
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor