def move(src, dst):
real_dst = dst<EOL>if os.path.isdir(dst):<EOL><INDENT>if _samefile(src, dst):<EOL><INDENT>os.rename(src, dst)<EOL>return<EOL><DEDENT>real_dst = os.path.join(dst, _basename(src))<EOL>if os.path.exists(real_dst):<EOL><INDENT>raise Error("<STR_LIT>" % real_dst)<EOL><DEDENT><DEDENT>try:<EOL><INDENT>os.rename(src, real_dst)<EOL><DEDENT>except OSError:<EOL><INDENT>if os.path.isdir(src):<EOL><INDENT>if _destinsrc(src, dst):<EOL><INDENT>raise Error("<STR_LIT>" % (src, dst))<EOL><DEDENT>copytree(src, real_dst, symlinks=True)<EOL>rmtree(src)<EOL><DEDENT>else:<EOL><INDENT>copy2(src, real_dst)<EOL>os.unlink(src)<EOL><DEDENT><DEDENT>
Recursively move a file or directory to another location. This is
    similar to the Unix "mv" command.

    If the destination is a directory or a symlink to a directory, the source
    is moved inside the directory. The destination path must not already
    exist.

    If the destination already exists but is not a directory, it may be
    overwritten depending on os.rename() semantics.

    If the destination is on our current filesystem, then rename() is used.
    Otherwise, src is copied to the destination and then removed.
    A lot more could be done here...  A look at a mv.c shows a lot of
    the issues this implementation glosses over.