Skip to content

Instantly share code, notes, and snippets.

@eloyz
Created September 20, 2011 17:10
Show Gist options
  • Save eloyz/1229680 to your computer and use it in GitHub Desktop.
Save eloyz/1229680 to your computer and use it in GitHub Desktop.
Random Characters
### one way ###
from string import letters
import random
rand_chars = ''.join(random.sample(letters, len(letters)))[:8]
### another way ###
from string import letters
from random import choice
rand_chars = ''.join([choice(letters) for i in xrange(8)])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment