def create_file(f): try: os.makedirs(os.path.dirname(f)) except OSError as exc: # Guard against race condition if exc.errno != errno.EEXIST: raise p_open(Res.mk_file + f)