os independent rename

Lee Harr missive at hotmail.com
Sat Sep 17 11:58:32 EDT 2011


I just got a bug report the heart of which is the
difference between unix and windows in using
os.rename

(ie, "On Windows, if dst already exists, OSError will be raised")

Hmm, I thought, maybe I'm supposed to use
shutil here. That is the "high-level" operations.
Unfortunately, shutil.move says it depends on
os.rename

So, what is the best way to do this that will
behave the same across operating systems?

 		 	   		  



More information about the Python-list mailing list