On Sun, Jan 17, 2010 at 5:19 PM, Alan Gauld <alan.ga...@btinternet.com> wrote:
>
> "Magnus Kriel" <magnus.kr...@gmail.com> wrote
>
>> It might be that when you create a file for the first time with 'a', that
>> it
>> will through an exception. So you will have to try with 'w', and if there
>> is
>> an exception, you know the file does not exist and you will have to create
>> the file for the first time with 'w'.
>
> That should not happen. If there is no file 'a' will act like 'w'


alan is correct. with 'a', if a file doesn't exist, it will create it
and open it for write. if it does exist, it will go to the current EOF
and open it for write starting from that point. the only time 'a'
throws an exception is if the file cannot be opened, e.g., it's on a
network drive that isn't there, no perms on that filesystem, etc.

-- wesley
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Python Web Development with Django", Addison Wesley, (c) 2009
    http://withdjango.com

wesley.j.chun :: wescpy-at-gmail.com
python training and technical consulting
cyberweb.consulting : silicon valley, ca
http://cyberwebconsulting.com
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to