Newbie question re: regsub

Darrell Gallion darrell at dorb.com
Sun Jul 2 23:02:57 EDT 2000


>>> open('junk','w').write("red red red red")
>>> import re
>>> print re.sub("red","orange", open('junk').read())
orange orange orange orange
>>>

The changed string is returned. Strings in python don't change so the
original buffer is unaffected.

--Darrell


----- Original Message -----
From: "Robert Goto" <rgoto at aa.net>

> What is even more maddening to me is that when I save it to a module and
run
> it from NT command prompt......the output I get is the original file
> contents only........like there was no regsub.gsub!!






More information about the Python-list mailing list