Is there a function to extract the extension from a filename?
import os.path extension = os.path.splitext(filename)[1][1:]
To get only the text of the extension, without the dot.