From: akuchlin at cnri.reston.va.us (Andrew M. Kuchling) Date: Mon, 19 Apr 1999 13:03:35 GMT Subject: How to merge data in a existant file In-Reply-To: <7feqbf$pr6$1@nnrp1.dejanews.com> References: <7feqbf$pr6$1@nnrp1.dejanews.com> Message-ID: <14107.10521.542022.542456@amarok.cnri.reston.va.us> X-UID: 87 fquiquet at lemel.fr writes: >I know how to write data in a new file : >I don't know what is the function that permit to add data whithout erase >existing data. Open the file in append mode, with a mode string of 'a' (or 'ab' for a binary file) instead of 'w'. >>> f = open('test-file', 'w') ; f.write('abc\n') ; f.close() >>> f = open('test-file', 'a') ; f.write('abc\n') ; f.close() >>> open('test-file', 'r').read() 'abc\012abc\012' -- A.M. Kuchling http://starship.python.net/crew/amk/ The NSA regularly lies to people who ask it for advice on export control. They have no reason not to; accomplishing their goal by any legal means is fine by them. Lying by government employees is legal. -- John Gilmore