[Tutor] 2 basic problems

Alan Gauld alan.gauld at btinternet.com
Sun Jun 16 19:09:06 CEST 2013


On 16/06/13 16:45, Chris “Kwpolska” Warrick wrote:

> Moreover, you could do it all in one step ('w+' stands for “clear file
> and allow read/write output”, while f.seek(0) is used to return the
> pointer back to the beginning of the file):

I'm always very wary of recommending mixed read/write mode to beginners.
Its simple in this case but in other scenarios its very easy to lose 
track of where the cursor is and start overwriting your previously 
written data!

I usually recommend writing the data, closing the file, and then opening 
for reading.

Powerful tools have the capacity to be powerfully bad as well
as good...

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/



More information about the Tutor mailing list