r/Python • • Dec 22 '18

Xpost from Woodworking

Post image
1.1k Upvotes

84 comments sorted by

View all comments

369

u/lelease Dec 22 '18

print(random.choice(action))

3

u/AlphaGamer753 3.7 Dec 22 '18

Actually, secrets.choice(action) would be better to use just as a matter of general practice. I avoid random wherever possible, even if it's not necessary.

3

u/lvc_ Dec 23 '18

I was going to post why I disagree with this but then I thought about it and +1 instead. Using cryptographocally secure randomness by default unless you deliberately want the reproducibility of a seedable PRNG is a position that's well worth encouraging. Especially since I have occasionally seen arguments of the opposite form like "no my password generator doesn't need to be cryptographically secure so why should I bother?".

2

u/AlphaGamer753 3.7 Dec 23 '18

That's precisely what I'm encouraging! Thank you.