Is there a way to filetype-check filename arguments using argparse? Seems like it could be done via the type or choices keyword if I can create the right type of container object.
I'm expecting a type of file passed in (say, file.txt) and want argparse to give its automatic message if the file is not of the right type (.txt). For example, argparse might output
usage: PROG --foo filename etc... error: argument filename must be of type *.txt.
Perhaps instead of detecting the wrong filetype, we could try to detect that filename string did not end with '.txt' but that would require a sophisticated container object.