[Tutor] open(file, 'rw') problem

Dave S pythontut at pusspaws.net
Thu Jul 27 10:12:11 CEST 2006


On Thursday 27 July 2006 09:08, Andre Engels wrote:
> 2006/7/27, Dave S <pythontut at pusspaws.net>:
> > It appears to be a problem with me opening the file as 'rw' although I
> > have googled and opening as 'rw' appears legal. Can you only open a file
> > as 'r' or 'w' -  ie open & close the file twice ?
>
> If you use "open(filename, 'rw')", the 'w' does not have effect, and
> you have opened the file read-only. To do what you want to do (both
> read and write with a file), you can use "open(filename, 'r+')"
> instead.

Ahh .. thanks for the heads up - I thought there had to be a better way

Cheers

dave


More information about the Tutor mailing list