The Python code is extremely simple and since it is from:
https://github.com/trezor/python-mnemonici assumed (wrongly?) that it is the way Trezor wallets generate their Bip39 mnemonic:
>>>from mnemonic import Mnemonic
>>>mnemo = Mnemonic("english")
>>>words = mnemo.generate(strength=128)
>>>print(words)
Is it safe to use?
Thanks:)
.
Looks okay to me, but I'm not exactly a security researcher. Your code looks okay assuming that the code is working as intended.