(old, new)
Renames file 'old' to 'new', works with separate partitions.
        Thanks to hannan.sadar
Renames file 'old' to 'new', works with separate partitions.
        Thanks to hannan.sadar
Renames file old to new works with separate partitions . Thanks to hannan . sadar
def rename(old, new):
    """
        Renames file 'old' to 'new', works with separate partitions.
        Thanks to hannan.sadar
    """
    try:
        os.rename(old, new)
    except os.error, detail:
        if detail.errno == errno.EXDEV:
            try:
                copy(old, new)
            except:
                os.unlink(new)
                raise
                os.unlink(old)
        # if desired, deal with other errors
        else:
            raise
def rename ( old , new ) : try : os . rename ( old , new ) except os . error , detail : if detail . errno == errno . EXDEV : try : copy ( old , new ) except : os . unlink ( new ) raise os . unlink ( old ) # if desired, deal with other errors else : raise