<s>[INST] Extracting extension from filename in Python Is there a function to extract the extension from a filename?
 [/INST] Yes. Use os.path.splitext:
>>> import os
>>> filename, file_extension = os.path.splitext('/path/to/somefile.ext')
>>> filename
'/path/to/somefile'
>>> file_extension
'.ext'

 </s>