CoCalc Public FilesClass Samples / file_exists.pyOpen with one click!
Author: Ryan McFall
Compute Environment: Ubuntu 20.04 (Default)
1
import os.path
2
3
from argparse import ArgumentParser
4
5
parser = ArgumentParser()
6
7
parser.add_argument('--file', required=True)
8
9
arguments = parser.parse_args()
10
11
if os.path.isfile(arguments.file):
12
print ("{} exists!".format(arguments.file))
13
else:
14
print ("{} does not exist!".format(arguments.file))