def secure_password(length=20, use_random=True):
 length = int(length)
 pw = ''
 while (len(pw) < length):
  if (HAS_RANDOM and use_random):
   pw += re.sub('\\W', '', Crypto.Random.get_random_bytes(1))
  else:
   pw += random.SystemRandom().choice((string.ascii_letters + string.digits))
 return pw

def secure_password ( length = 20 , use_random = True ) : length = int ( length ) pw = '' while ( len ( pw ) < length ) : if ( HAS_RANDOM and use_random ) : pw += re . sub ( '\\W' , '' , Crypto . Random . get_random_bytes ( 1 ) ) else : pw += random . SystemRandom ( ) . choice ( ( string . ascii_letters + string . digits ) ) return pw
generate a secure password .