I\'m interested in creating a very simple, high (cryptographic) quality random password generator. Is there a better way to do this?
import os, random, strin
Implenting @Thomas Pornin solution (can't comment @Yossi inexact answer):
import string, os
chars = string.ascii_letters + string.digits + '+/'
assert 256 % len(chars) == 0 # non-biased later modulo
PWD_LEN = 16
print(''.join(chars[c % len(chars)] for c in os.urandom(PWD_LEN)))
UPDATED for python3 thank to Stephan Lukits