def editapache(self,oldmail,mail,name,oldname,charset,oldcharset,vhid):
with open(filename,'r+') as config:
config.replace(oldcharset,charset)
config.replace(oldname,name)
config.replace(oldmail,mail)
config.write(config)
def editapache(self,oldmail,mail,name,oldname,charset,oldcharset,vhid):
with open(filename,'r+') as config:
map(config.replace, [oldmail, oldname, oldcharset], [mail, name, charset])
config.write(config)
def editapache(self,replacements):
with open(filename,'r+') as config:
for _from,_to in replacements:
config.replace(_from,_to)
config.write(config)
....
editapache(self,[(oldcharset,charset),(oldmail,mail),(oldname,name),("oldstring","newstring")])
config = "1 2 3 4 5 6"
substitutions = {"2":"7", "3":"6"}
def replace_all(text, dic):
for i, j in dic.iteritems():
text = text.replace(i, j)
return text
print replace_all(config, substitutions)