[OFF] sed equivalent of something easy in python
Mark Wooding
mdw at distorted.org.uk
Sat Oct 30 11:14:38 EDT 2010
Jussi Piitulainen <jpiitula at ling.helsinki.fi> writes:
> Daniel Fetchinson writes:
>
> > The pattern is that the first line is deleted, then 2 lines are
> > kept, 3 lines are deleted, 2 lines are kept, 3 lines are deleted,
> > etc, etc.
>
> So, is there some simple expression in Python for this?
(item for i, item in enumerate(input) if (i + 4)%5 < 2)
-- [mdw]
More information about the Python-list
mailing list