Extracting extension from filename in Python
Question: Is there a function to extract the extension from a filename?


Answer: Yes. Use
[`os.path.splitext`](https://docs.python.org/2/library/os.path.html#os.path.splitext):

    
    
    >>> import os
    >>> filename, file_extension = os.path.splitext('/path/to/somefile.ext')
    >>> filename
    '/path/to/somefile'
    >>> file_extension
    '.ext'
    

