Hi, I just started with argparse. I want to simply check the extension of the file that the user passes to the program. I get a ''file' object has no attribute 'rfind'' error when I use os.path.splitext(args.infile). Here is my code.
import argparse, sys, os des = 'Get restraint definitions from probe.' parser = argparse.ArgumentParser(description=des) parser.add_argument('infile', nargs='?', type=argparse.FileType('r')) # parser.add_argument('outfile', nargs='?', type=argparse.FileType('w'), # default=sys.stdout) args = parser.parse_args() # print args.infile.readlines() print basename, extension = os.path.splitext(args.infile) There may be a better way to check extensions using argparse. Any help will be appreciated. Thanks, Bradley -- Bradley J. Hintze Graduate Student Duke University School of Medicine -- http://mail.python.org/mailman/listinfo/python-list