[Python-ideas] Rewriting file - pythonic way

Alexey Shrub ashrub at yandex.ru
Mon Apr 16 07:47:23 EDT 2018


В Воскресенье, 15 апр. 2018 в 1:12 , Serhiy Storchaka 
<storchaka at gmail.com> написал:
> Actually the reliable code should write into a separate file and 
> replace
> the original file by the new file only if writing is successful. Or
> backup the old file and restore it if writing is failed. Or do both. 
> And
> handle hard and soft links if necessary. And use file locks if needed 
> to
> prevent race condition when read/write by different processes. 
> Depending
> on the specific of the application you may need different code. Your
> three lines are enough for a one-time script if the risk of a powerful
> blackout or disk space exhaustion is insignificant or if the data is 
> not
> critical.

I not sure that solving described problems is a task of this level, 
maybe it problem for higher level



More information about the Python-ideas mailing list