Re: [Tutor] A further question about opening and closing files

2015-09-10 Thread Laura Creighton
In a message of Wed, 09 Sep 2015 23:19:43 +0100, Alan Gauld writes: >..., if your game engine is running on a server shared by other users and >some of them are running critical apps (think a businesses billing or >accounting suite that must complete its run within a 1 hour window say) >then

Re: [Tutor] A further question about opening and closing files

2015-09-10 Thread Alan Gauld
On 10/09/15 16:44, Laura Creighton wrote: ..., if your game engine is running on a server shared by other users and some of them are running critical apps (think a businesses billing or We were talking about mobile devices ... Ok, in that case I'd guess the client playing the game is only

[Tutor] A further question about opening and closing files

2015-09-09 Thread richard kappler
Under a different subject line (More Pythonic?) Steven D'Aprano commented: > And this will repeatedly open the file, append one line, then close it > again. Almost certainly not what you want -- it's wasteful and > potentially expensive. And I get that. It does bring up another question though.

Re: [Tutor] A further question about opening and closing files

2015-09-09 Thread Laura Creighton
>I did a little experiment: > f1 = open("output/test.log", 'a') f1.write("this is a test") f1.write("this is a test") f1.write('why isn\'t this writing') f1.close() If you want the thing written out, use f1.flush() whenever you want to make sure this happens. If you

Re: [Tutor] A further question about opening and closing files

2015-09-09 Thread richard kappler
Thanks, tried them both, both work great on Linux. Now I understand better. regards, Richard On Wed, Sep 9, 2015 at 11:28 AM, Laura Creighton wrote: > >I did a little experiment: > > > f1 = open("output/test.log", 'a') > f1.write("this is a test") >

Re: [Tutor] A further question about opening and closing files

2015-09-09 Thread Alan Gauld
On 09/09/15 20:42, Laura Creighton wrote: In a message of Wed, 09 Sep 2015 20:25:06 +0100, Alan Gauld writes: On 09/09/15 19:20, Laura Creighton wrote: If you are working on a small platform - think mobile device - and it has a single channel bus to the storage area then one of the worst things

Re: [Tutor] A further question about opening and closing files

2015-09-09 Thread Steven D'Aprano
On Wed, Sep 09, 2015 at 08:20:44PM +0200, Laura Creighton wrote: > In a message of Wed, 09 Sep 2015 17:42:05 +0100, Alan Gauld writes: > >You can force the writes (I see Laura has shown how) but > >mostly you should just let the OS do it's thing. Otherwise > >you risk cluttering up the IO bus and

Re: [Tutor] A further question about opening and closing files

2015-09-09 Thread Steven D'Aprano
On Wed, Sep 09, 2015 at 10:24:57AM -0400, richard kappler wrote: > Under a different subject line (More Pythonic?) Steven D'Aprano commented: > > > And this will repeatedly open the file, append one line, then close it > > again. Almost certainly not what you want -- it's wasteful and > >

Re: [Tutor] A further question about opening and closing files

2015-09-09 Thread Alan Gauld
On 09/09/15 15:24, richard kappler wrote: f1 = open("output/test.log", 'a') f1.write("this is a test") f1.write("this is a test") f1.write('why isn\'t this writing') f1.close() monitoring test.log as I went. Nothing was written to the file until I closed it, or at least that's the way it

Re: [Tutor] A further question about opening and closing files

2015-09-09 Thread Laura Creighton
In a message of Wed, 09 Sep 2015 17:42:05 +0100, Alan Gauld writes: >You can force the writes (I see Laura has shown how) but >mostly you should just let the OS do it's thing. Otherwise >you risk cluttering up the IO bus and preventing other >programs from writing their files. Is this something

Re: [Tutor] A further question about opening and closing files

2015-09-09 Thread Alan Gauld
On 09/09/15 19:20, Laura Creighton wrote: In a message of Wed, 09 Sep 2015 17:42:05 +0100, Alan Gauld writes: You can force the writes (I see Laura has shown how) but mostly you should just let the OS do it's thing. Otherwise you risk cluttering up the IO bus and preventing other programs from

Re: [Tutor] A further question about opening and closing files

2015-09-09 Thread Laura Creighton
In a message of Wed, 09 Sep 2015 20:25:06 +0100, Alan Gauld writes: >On 09/09/15 19:20, Laura Creighton wrote: >If you are working on a small platform - think mobile device - and it has >a single channel bus to the storage area then one of the worst things >you can do is write lots of small chunks