I'm reading a file and replacing a text string. I'm doing this for a few different strings, I know this isn't the most effeciant code I'm just trying to get it working. Here's what I have:
for line in fileinput.input(new_config, inplace=1):
print line.replace("http://domain.com", self.site_address)
print line.replace("dbname", self.db_name)
print line.replace("root", self.db_user)
print line.replace("password", self.db_pass)
print line.replace("smvc_", self.prefix
this works but it also writes every line in the file 5 times and only replaces the string on the first attempt on not on the new lines it creates (doesn't matter if it matches the string or not)