comparing a directory to current dir...

Bjorn Pettersen bjorn at roguewave.com
Tue Jul 11 18:14:54 EDT 2000


I have a directory (and a filename), and I want to copy the filename
from that directory to my current directory. The problem is, I only want
to do this if the directories are not equal...

I tried the following:

  if os.path.abspath(os.curdir) != os.path.abspath(directory):
      shutil.copy( os.path.join(directory, filename), os.curdir )

the problem is that os.path.abspath(os.curdir) contains the drive letter
on Windows and os.path.abspath(directory) doesn't.

Is this a bug in os.path.abspath? (I can't think of an instance where
the current behavior would be useful -- but that could just be lack of
imagination <wink>).

-- bjorn




More information about the Python-list mailing list