def check_exists ( filename , oappend = False ) : if op . exists ( filename ) : if oappend : return oappend logging . error ( "`{0}` found, overwrite (Y/N)?" . format ( filename ) ) overwrite = ( raw_input ( ) == 'Y' ) else : overwrite = True return overwrite
python not to ask overwrite a file
Avoid overwriting some files accidentally .
def check_exists(filename, oappend=False):
    """
    Avoid overwriting some files accidentally.
    """
    if op.exists(filename):
        if oappend:
            return oappend
        logging.error("`{0}` found, overwrite (Y/N)?".format(filename))
        overwrite = (raw_input() == 'Y')
    else:
        overwrite = True

    return overwrite