DEV Community

Discussion on: What I've Learned Being a Self-Taught Developer

Collapse
 
adammarples profile image
adammarples
import string
import random

chars = string.ascii_lower + string.ascii_upper + string.punctuation

pw = ''.join([random.choice(chars) for _ in range(pw_length)])
Collapse
 
kaelscion profile image
kaelscion

Very nice way to generate a password! Wrap that in a function that takes the argument pw_length and and you'd be able to generate a good password of any length quite quickly. I'm guessing you've seen something similar I developed on my GitHub profile? I will absolutely admit that the use of the string class rather than a list of characters is a nice touch and, admittedly, one I did not think of. Send me a pull request and I'll merge it (hurry though cuz I'll do it myself before long then you'll be minus a commit on your profile 😜😜

Collapse
 
adammarples profile image
adammarples

You go ahead, you're the "toughest developer in the room" after all. If you want the class to be useful, it should include options for common requirements like passwords with no special characters and at least one capital and number, etc.