def token_generator(length=32):
    ' Generate a random token for use in passwords and account tokens.\n\n    param: length - the length of the token to generate'
    alpha = (string.ascii_letters + string.digits)
    token = ''.join((random.SystemRandom().choice(alpha) for _ in range(length)))
    return token
Generate a random token for use in passwords and account tokens.

param: length - the length of the token to generate
def token_generator(length=32):
    ' Generate a random token for use in passwords and account tokens.\n\n    param: length - the length of the token to generate'
    alpha = (string.ascii_letters + string.digits)
    token = .join((random.SystemRandom().choice(alpha) for _ in range(length)))
    return token