I can do it in sed...

Kotlin Sam xavier_onasis at hotmail.com
Thu Mar 17 01:01:47 CET 2005

I have spent so much time using sed and awk that I think that way. Now, 
when I have to do some Python things, I am having to break out of my 
sed-ness and awk-ness, and it is causing me problems. I'm trying. Honest!

Here are the two things that I'm trying to do:
	In sed, I can print every line between ^start to ^end by using 
/^start/,/^end/p. It's quick, easy, and doesn't take much time. Is there 
  a way to do this easily in Python?

	Also, I frequently use something like s/^[A-Z]/~&/ to pre-pend a tilde 
or some other string to the beginning of the matched string. I know how 
to find the matched string, but I don't know how to change the beginning 
of it while still keeping the matched part.

If I were able to stay in the *nix environment for all my work, I could 
do it with these tools and the beloved pipe(|), but that isn't my lot in 
life. I would do it in Perl, but, frankly, it gives me headaches even 
looking at it.

Any ideas?

Thanks, Lance

More information about the Python-list mailing list