title: Python argparse compare input and default file names and types are same?
body: <pre><code>def check_file(user_name,default_name):
      while True:
          try:
              #### check user name matches the default name
              if ('%s'%(user_name)) == '%s'%(default_name):
                  print(&quot;file matches&quot;)
                  break
          except:
              print(&quot;wrong file.&quot;)
              continue
  if __name__ == '__main__':
      parser = argparse.ArgumentParser()
      parser.add_argument('-k1',type=argparse.FileType('r'),default='k1file.txt',required=True,
                          help='file input')
  
      parser.add_argument('-k2',type=argparse.FileType('r'),default='k2file.txt',required=True,
                          help='file input')    
      args = parser.parse_args()
      check_file(args.k1,args.get_default('k1'))
      check_file(args.k2,args.get_default('k2'))
  </code></pre>
  <p>Present output:</p>
  <pre><code>AttributeError: 'Namespace' object has no attribute 'k1'
  </code></pre>