Hi,
I've encountered a problem iwhile writing a find and replace prg in python.
this is my code:
import re
f = file('testfile')
while True:
line = f.readline()
if len(line) == 0:
break
print line
p = re.compile(line)
m = p.match('METASERV_HOME')
print m
f.close()
as per the logic :
if my testfile contains METASERV_HOME, then i shld be getting an instance of "matching object"
otherwise , "none"
but instead of the former result, i am getting just none.
i want to know if i have done something wrong in reading a file.
print line....in the prg correctly reads the first line in the textfile.
for testing pupose my textfile has only 2 lines in the file and both of them are METASERV_HOME.
here is the output:
C:\python>python findnreplace.py
METASERV_HOME
None
METASERV_HOME
None
so where wud the problem be.?
kindly help me on this,
Thanks in advance,
Harini
Edit: Added code tags vegaseat