[python-win32] Suggested change to document.py

Tim Roberts timr at probo.com
Thu Nov 2 22:52:19 CET 2006


Gerard Brunick wrote:
> ...I run windows XP, and I keep
> python scripts all over my drive.  Rather than adding all sorts of 
> subdirectory's to my path, i create
> hardlinks to the scripts that I need to use from the command line in a 
> single \bin directory.
> ...
> The solution seems to be change
> pythonwin\pywin\framework\editor\document.py line 70
> from: os.rename(fileName, bakFileName)
> to: something like shutil.copy(fileName, bakFileName)
> and adding "import shutil" at the top
>
> This seems to work for me.

Very interesting.  This is a problem that Unix folks have faced since
time immemorial, but virtually no one uses hard links in Windows.

The advantage of the os.rename method is performance, but since Python
scripts are always too small to worry about, I'd be in favor of this
change, assuming we used shutil.copy2 to retain the dates and times.

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the Python-win32 mailing list