code: def password(rest):
  	
  	charsets = [
  		string.ascii_lowercase,
  		string.ascii_uppercase,
  		string.digits,
  		string.punctuation,
  	]
  	passwd = []
  
  	try:
  		length = rest.strip() or 12
  		length = int(length)
  	except ValueError:
  		return 'need an integer password length!'
  
  	for i in range(length):
  		passwd.append(random.choice(''.join(charsets)))
  
  	if length >= len(charsets):
  		# Ensure we have at least one character from each charset
  		replacement_indices = random.sample(range(length), len(charsets))
  		for i, charset in zip(replacement_indices, charsets):
  			passwd[i] = random.choice(charset)
  
  	return ''.join(passwd)
docs: Generate a random password, similar to
  	http://www.pctools.com/guides/password