Re: [OFF] sed equivalent of something easy in python

2010-10-30 Thread Mark Wooding
Jussi Piitulainen 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 enumera

Re: [OFF] sed equivalent of something easy in python

2010-10-27 Thread Arnaud Delobelle
Tim Chase writes: > On 10/27/10 09:39, Jussi Piitulainen wrote: >>> So, is there some simple expression in Python for this? Just asking >>> out of curiosity when nothing comes to mind, not implying that there >>> should be or that Python should be changed in any way. >> >> To expand, below is the

Re: [OFF] sed equivalent of something easy in python

2010-10-27 Thread Tim Chase
On 10/27/10 09:39, Jussi Piitulainen wrote: So, is there some simple expression in Python for this? Just asking out of curiosity when nothing comes to mind, not implying that there should be or that Python should be changed in any way. To expand, below is the best I can think of in Python 3 and

Re: [OFF] sed equivalent of something easy in python

2010-10-27 Thread Jussi Piitulainen
Jussi Piitulainen writes: > Daniel Fetchinson writes: > > > This question is really about sed not python, hence it's totally > > off. But since lots of unix heads are frequenting this list I > > thought I'd try my luck nevertheless. > ... > > using python. The pattern is that the first line is de

Re: [OFF] sed equivalent of something easy in python

2010-10-27 Thread Jussi Piitulainen
Daniel Fetchinson writes: > This question is really about sed not python, hence it's totally > off. But since lots of unix heads are frequenting this list I > thought I'd try my luck nevertheless. ... > using python. The pattern is that the first line is deleted, then 2 > lines are kept, 3 lines

Re: [OFF] sed equivalent of something easy in python

2010-10-25 Thread Daniel Fetchinson
>> using python. 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. > > If you have GNU sed, you can use > >sed -n '2~5{N;p}' > > which makes use of the GNU "~" extension. If you need a more > portabl

Re: [OFF] sed equivalent of something easy in python

2010-10-25 Thread Tim Chase
On 10/25/2010 11:25 AM, Daniel Fetchinson wrote: using python. 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. If you have GNU sed, you can use sed -n '2~5{N;p}' which makes use of the GNU "~" extens

[OFF] sed equivalent of something easy in python

2010-10-25 Thread Daniel Fetchinson
This question is really about sed not python, hence it's totally off. But since lots of unix heads are frequenting this list I thought I'd try my luck nevertheless. If I have a file with content 1 2 3 4 5 6 7 8 ... i.e. each line contains simply its line number, then it's quite easy to conve