Why doesn't this work? - comparing read lines from a file - string.replace question also.
pyth at devel.trillke.net
Fri Aug 30 23:33:12 CEST 2002
Micah Mayo wrote:
> 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!
> import string
> orig = 'sendmail_enable="YES"'
> pref = 'sendmail_enable="NONE"'
> for eachLine in open('rc.conf','r+'):
> print orig,'\n',eachLine
> if eachLine == orig:
eachLine has a trailing newline while your 'orig' string has not. try
More information about the Python-list