Use shutil.copyfile , this does not require the full path.
Removing os.chmod all over the world is not a good idea.
$ mkdir folder $ touch folder/a $ python2.7 -c 'import shutil; shutil.copyfile("folder/a","folder/b")' $ ls -rthla folder/ total 0 drwxr-xr-x+ Apr 17 12:49 ../ -rw-r--r-- Apr 17 12:49 a -rw-r--r-- Apr 17 12:50 b drwxr-xr-x+ Apr 17 12:50 ./
As you can see in the python source code for shutil ( /usr/lib/python2.7/shutil.py ), there is no path in the copy source code (relative / absolute), the src variable is directly passed as the copyfile argument.
def copy(src, dst): """Copy data and mode bits ("cp src dst"). The destination may be a directory. """ if os.path.isdir(dst): dst = os.path.join(dst, os.path.basename(src)) copyfile(src, dst) copymode(src, dst)
source share