Why doesn't this work? - comparing read lines from a file - string.replace question also.
astrophels at yahoo.com
Fri Aug 30 23:24:31 CEST 2002
I have this little bit of code, that reads the standard rc.conf file
that is installed with freebsd. I don't understand why a simple if
statement is not working, please help!
orig = 'sendmail_enable="YES"'
pref = 'sendmail_enable="NONE"'
for eachLine in open('rc.conf','r+'):
if eachLine == orig:
print '..replacing', orig, 'with',pref
# will add code to replace eachLine w/ pref later
and here is the result I get:
As far as I can tell, they are equal, why isn't it going to the right
part of the loop?
Also, as you can see, I wish to replace what's in the file with the
'preg' variable. I was thinking about using string.replace, perhaps
Any comments on how to do this, or a better way of running this loop?
Thanks in advance,
More information about the Python-list