title: Python: A way to detect a filetype attached to a string?
body: <p>In IronPython 2.6*, I'm trying to build a function that "corrects" a string; I have two arguments, <code>FILE</code> and <code>EXTN</code>. The idea is for them to be concatenated as necessary later in the program, but you know some people don't read instructions and you're bound to have someone enter <code>"FILE.*"</code> as their <code>FILE</code>, which would mess everything up.</p>
  
  <p>I'm looking for a way to take <code>FILE</code>, have my function detect and strip <code>.*</code> (<em>any</em> extension of any length) from <code>FILE</code> <em>if .* exists</em>; It doesn't need to be in the string, and the user will be entering the same extension into <code>EXTN</code>**, so it needs not be prepared, merely consistently stripped.</p>
  
  <p>My current method has me passing <code>FILE</code> and <code>EXTN</code> separately, but it's not inconceivable to redo things to take <code>FILE.EXTN</code> and break that into <code>FILE</code> and <code>EXTN</code> if need be; I don't want to if I don't have to, though, as my program is built around the former system.</p>
  
  <p>*A note regarding IronPython 2.6; I'm trying to avoid IronPython-specific codes and use as simple of ones as possible, for UNIX-WIN cross-compatibility's sake. So far, everything I've done works in Python 2.7 IDE's, but obviously will not work in Python 3.x</p>
  
  <p>**A note regaring <code>EXTN</code>; I <em>want</em> users to enter the proper extension into <code>EXTN</code> too, but as we know, we can't be sure of this and so the method for stripping <em>.i</em> from <code>FILE</code> must not automatically include <code>EXTN</code> as part of it.</p>
  
  <p>Here is a snippet of code that may help as a reference for what I have so far. The <code>FILE</code> and <code>EXTN</code> variables have been added, and in practice, are pulled in through a middle-man program from an XML file into the script at run-time.</p>
  
  <pre><code>FILE = "test"
  PATH = "C:\\"
  EXTN = ".txt"
  
  def CheckCorrect_FILE(srcFile): #Check-corrects FILE
      #Meh, I got nothin'...
  
  def CheckCorrect_PATH(srcPath): #Check-corrects PATH
      if srcPath.endswith('\\') == False:
          srcPath = srcPath + "\\"
      else:
          srcPath = srcPath
      return srcPath
  </code></pre>