def rand_password(length=15):
 upper = random.choice(string.ascii_uppercase)
 ascii_char = string.ascii_letters
 digits = string.digits
 digit = random.choice(string.digits)
 puncs = '~!@#%^&*_=+'
 punc = random.choice(puncs)
 seed = ((ascii_char + digits) + puncs)
 pre = ((upper + digit) + punc)
 password = (pre + ''.join((random.choice(seed) for x in range((length - 3)))))
 return password

def rand_password ( length = 15 ) : upper = random . choice ( string . ascii_uppercase ) ascii_char = string . ascii_letters digits = string . digits digit = random . choice ( string . digits ) puncs = '~!@#%^&*_=+' punc = random . choice ( puncs ) seed = ( ( ascii_char + digits ) + puncs ) pre = ( ( upper + digit ) + punc ) password = ( pre + '' . join ( ( random . choice ( seed ) for x in range ( ( length - 3 ) ) ) ) ) return password
generate a random password .