I use argparse to get the file from the user:
import argparse, os parser = argparse.ArgumentParser() parser.add_argument('file', type=file) args = parser.parse_args()
Then I want to know the directory in which this file is, something like:
print(os.path.abspath(os.path.dirname(args.inputfile)))
But of course, since args.inputfile is a file object, this does not work. How to do it?
python path argparse
Stéphane pechard
source share