On May 1, 6:43 am, loial <[EMAIL PROTECTED]> wrote: > OK, I have it working with dictionaries. > > However I have another scenerio : > > I am reading a file containing records like the following : > > <IMPOSITION_DOCUMENT> > <WFBAN_PAGE> > <WFBAN_START_DETAILS name=\""MYVARIABLE"\"> > .. > .. > > I need to substitute MYVARIABLE with the current value of MYVARIABLE > in my python script and write the file out again. > > The file may contain many more lines and many substitution values on > any line > > Assuming that MYVARIABLE is currently set to JOHN then the output > would be > > <IMPOSITION_DOCUMENT> > <WFBAN_PAGE> > <WFBAN_START_DETAILS name="JOHN"> > > Can this be done in Python?
s = "hello world, goodbye world" result = s.replace("world", "moon") print result -- http://mail.python.org/mailman/listinfo/python-list