yes thanks both work nicely, I will ponder the suggestions.
--
http://mail.python.org/mailman/listinfo/python-list
On Apr 5, 3:59 am, Martin De Kauwe wrote:
> Hi,
>
> So i want to replace multiple lines in a text file and I have reasoned
> the best way to do this is with a dictionary. I have simplified my
> example and broadly I get what I want however I am now printing my
> replacement string and part of the
How about creating a new string instead of replacing the original.
def replace_keys(text, replacements_dict):
text_list = text.split('\n')
new_text = ''
for line in text_list:
key=line.split('=')[0]
if key.strip() in replacements_dict:
new_text = new_text +
2011/4/5 Martin De Kauwe :
> Hi,
>
> So i want to replace multiple lines in a text file and I have reasoned
> the best way to do this is with a dictionary. I have simplified my
> example and broadly I get what I want however I am now printing my
> replacement string and part of the original express
Hi,
So i want to replace multiple lines in a text file and I have reasoned
the best way to do this is with a dictionary. I have simplified my
example and broadly I get what I want however I am now printing my
replacement string and part of the original expression. I am guessing
that I will need to