I can do it in sed...

John Machin sjmachin at lexicon.net
Wed Mar 16 20:24:35 EST 2005


Kotlin Sam wrote:
> 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.

You can get gnu Windows versions of awk sed and most other suchlike
goodies off the net ...




More information about the Python-list mailing list