Is there a function to extract the extension from a filename?
Even this question is already answered I'd add the solution in Regex.
>>> import re >>> file_suffix = ".*(\..*)" >>> result = re.search(file_suffix, "somefile.ext") >>> result.group(1) '.ext'