Python closes files at the end of a with statement scope. It will also close the file cleanly if an exception is thrown.  That's what I call KISS!

with open('file_path', 'w') as file:
    file.write('hello world !')


On 20/06/2022 1:47 pm, Peter Sylvester wrote:
Hi,

I remember I did that 25 years ago something like (was actually in perl on windows):

  open(path/prefix-current_day_or_so, |O_WRONLY|O_APPEND|)"
  write(..)
  cliose(..)
  fsync(...)

(error treating TDB).

KISS  ?

( If you are paranoiac, use three copies, or else  :-)

Peter
peter.sylvester (a) could


On 19/06/2022 22:35, Farley, Peter x23353 wrote:
Agreed; I did not spell out all the details, silly me.

close(old)
rename(old)
open(new)

Peter



----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to