deleting texts between patterns

bruno at modulix onurb at xiludom.gro
Fri May 12 07:50:52 EDT 2006


bruno at modulix wrote:
> micklee74 at hotmail.com wrote:
> 
(snip)
> 
> Don't know if it's better for your actual use case, but this avoids
> reading up the whole file:

> def skip(iterable, skipfrom, skipuntil):
>     """ example usage :
>     >>> f = open("/path/to/my/file.txt")
>     >>> for line in skip_print(f, 'abc', 'yyz'):
>     >>>     print line
>     >>> f.close()
>     """
(snip code)

Forgot to say this will also skip markers. If you want to keep them, see
the effbot answer...

-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"



More information about the Python-list mailing list