Created
March 21, 2014 12:17
-
-
Save ColtonPhillips/9684986 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
def rstr(length=5, special_chars=True, numbers=True, upper_case=True): | |
chars = string.ascii_lowercase | |
chars += string.ascii_uppercase if upper_case else '' | |
chars += string.digits if numbers else '' | |
chars += string.punctuation if special_chars else '' | |
return ''.join(random.choice(chars) for i in range(length)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment