Re: [Tutor] file read and write

2007-09-11 Thread Kent Johnson
le dahut wrote: > I noticed that it is possible to write this : > """ > file('/tmp/myfile', 'w').write('Hello world\n') ISTM I have had trouble with this. I always explicitly close a file that is open for writing. > contnt = file('/tmp/sourcefile').read() I use this often but never in any kind

Re: [Tutor] file read and write

2007-09-11 Thread Alan Gauld
"le dahut" <[EMAIL PROTECTED]> wrote >I noticed that it is possible to write this : > """ > file('/tmp/myfile', 'w').write('Hello world\n') > contnt = file('/tmp/sourcefile').read() > """ Yes, it just creates temporary objects and relies on garbage collection to close/dispose of them. > inste

[Tutor] file read and write

2007-09-11 Thread le dahut
I noticed that it is possible to write this : """ file('/tmp/myfile', 'w').write('Hello world\n') contnt = file('/tmp/sourcefile').read() """ instead of : """ fh = file('/tmp/myfile', 'w') fh.write('Hello world\n') fh.close() fh = file('/tmp/sourcefile') contnt = fh.read() fh.close() """ is ther