Make a backup file: Difference between revisions

→‎{{header|Python}}: greetings from pycon china 2011
(→‎{{header|Python}}: greetings from pycon china 2011)
Line 81:
mv(targetfile, targetfile+"~");
Stdio.write_file(targetfile, "this task was solved at the pycon china 2011");</lang>
 
=={{header|Python}}==
<lang Python>
import os
targetfile = "pycon-china"
os.rename(os.path.realpath(targetfile), os.path.realpath(targetfile)+".bak")
f = open(os.path.realpath(targetfile), "w")
f.write("this task was solved during a talk about rosettacode at the PyCon China in 2011")
f.close()
</lang>
 
=={{header|Ruby}}==
This version does not overwrite the backup file if it exists.
Anonymous user