def get_file_extension ( filename ) : filename_x = filename . split ( '.' ) if len ( filename_x ) > 1 : if filename_x [ - 1 ] . strip ( ) is not '' : return filename_x [ - 1 ] return None
python how to get the file extension
Return the extension if the filename has it . None if not .
def get_file_extension(filename):
    """ Return the extension if the filename has it. None if not.

    :param filename: The filename.
    :return: Extension or None.
    """
    filename_x = filename.split('.')
    if len(filename_x) > 1:
        if filename_x[-1].strip() is not '':
            return filename_x[-1]
    return None