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:)
The code is from:
https://github.com/trezor/python-mnemonic/blob/master/src/mnemonic/mnemonic.py.
Looks okay to me, but I'm not exactly a security researcher. Your code looks okay assuming that the code is working as intended.
The link is very interesting indeed. Here is a script:
import random
from datetime import datetime
random.seed(datetime.now().timestamp())
T=[]
for i in range(127):
x=random.random()
if x<0.5:
T.append(0)
else:
T.append(1)
print(T)
Not sure if it is better than the previous method though...
Edit: Please do not use anything that can be determined as seed when you're trying to generate something random. Use the secrets module, and if you're unsure about how exactly CSPRNG should be implemented, don't touch it or you might inadvertently generate something insecure.