pybitcointools (https://github.com/primal100/pybitcointools) generates a bitcoin private key using the following function (in main.py: https://github.com/primal100/pybitcointools/blob/master/cryptos/main.py):
import hashlib
def random_key():
entropy = random_string(32) \
+ str(random.randrange(2**256)) \
+ str(int(time.time() * 1000000))
return sha256(entropy)
in other places I saw a simpler implementation:
import os
os.urandom(32).hex()
I wonder which is more random, what is safer to use?