from unidecode import unidecode
import time

def anagrammes(mot):
    if len(mot) == 1:
        yield mot
    else :
        for z in set(mot): # set(mot) permet de créer un ensemble de lettres DISTINCTES
            i = mot.index(z)
            for sm in anagrammes( mot[0:i] + mot[i+1:] ):
                yield z + sm

def anag(mot):
    mot = mot.upper()
    M = []
    
    # on construit une liste des mots de même longueur que 'mot'
    
    with open('mots.txt' , 'r' , encoding='utf-8') as w:
        for l in w:
            if len(l[:-1]) == len(mot) and unidecode(l[:-1]) not in M:
                M.append(unidecode(l[:-1]))
    
    L = [ word for word in M if word in anagrammes(mot) ]
        
    return L

start = time.time()
print( anag('python') )
end = time.time()
print(end - start)