title: python argparse.FileType('w') check extension
body: <p>The <em>argparse</em> package does a great job when dealing with command line arguments. I'm wondering however if there is any way to ask argparse to check for file extension (e.g ".txt"). The idea would be to derived one the class related to <em>argparse.FileType</em>. I would be interested in any suggestion. </p>
  
  <p>Keep in mind that I have more than 50 subcommands in my program all having there own CLI. Thus, I would be interest in deriving a class that could be imported in each of them more than adding some uggly tests in all my commands. </p>
  
  <p>Thanks a lot.</p>
  
  <pre><code># As an example one would be interested in turning this...
  parser_grp.add_argument('-o', '--outputfile',
                          help="Output file.",
                          default=sys.stdout,
                          metavar="TXT",
                          type=argparse.FileType('w'))
  
  
  # Into that...
  from somewhere import FileTypeWithExtensionCheck 
  parser_grp.add_argument('-o', '--outputfile',
                          help="Output file.",
                          default=sys.stdout,
                          metavar="TXT",
                          type=FileTypeWithExtensionCheck('w', '.[Tt][Xx][Tt]$'))
  </code></pre>