def print_file(dir, file): path = Path(dir + '/' + file) if path.exists(): try: with path.open('r') as fd: print(fd.read()) except IOError as err: print(err)
def create_dir(): dirname = "useless_dir" path = Path(dirname) try: if path.exists() is False: path.mkdir() except OSError as err: print("Creation of the directory {dir} failed".format(dir=dirname)) print(err) return dirname