I\'dl like to generate some alphanumeric passwords in python. Some possible ways are:
import string
from random import sample, choice
chars = string.letters
WARNING this answer should be ignored due to critical security issues!
Option #2 seems quite reasonable except you could add a couple of improvements:
''.join(choice(chars) for _ in range(length)) # in py2k use xrange
_
is a conventional "I don't care what is in there" variable. And you don't need list comprehension there, generator expression works just fine for str.join
. It is also not clear what "slow" means, if it is the only correct way.