 <p>'12.10.13_file' as a filename, does have '13_file' as it's file extension. At least regarding the file system. </p> <p>But, instead of finding the last . yourself, use <a href="http://docs.python.org/library/os.path.html#os.path.splitext" rel="nofollow">os.path.splitext</a>:</p> <pre><code>import os fileName, fileExtension = os.path.splitext('/path/yourfile.ext') # Results in: # fileName = '/path/yourfile' # fileExtension = '.ext' </code></pre> <p>If you want to exclude certain extensions, you could blacklist those after you've used the above.</p>