def generate_password(length=20, symbolgroups=DEFAULT_PASSWORD_SYMBOLS):
 r = random.SystemRandom()
 password = [r.choice(s) for s in symbolgroups]
 r.shuffle(password)
 password = password[:length]
 length -= len(password)
 symbols = ''.join(symbolgroups)
 password.extend([r.choice(symbols) for _i in xrange(length)])
 r.shuffle(password)
 return ''.join(password)

def generate_password ( length = 20 , symbolgroups = DEFAULT_PASSWORD_SYMBOLS ) : r = random . SystemRandom ( ) password = [ r . choice ( s ) for s in symbolgroups ] r . shuffle ( password ) password = password [ : length ] length -= len ( password ) symbols = '' . join ( symbolgroups ) password . extend ( [ r . choice ( symbols ) for _i in xrange ( length ) ] ) r . shuffle ( password ) return '' . join ( password )
generate internal password for externally authenticated user .