Skip to content

Instantly share code, notes, and snippets.

@MiCurry
Created November 14, 2017 00:56
Show Gist options
  • Save MiCurry/6cbd4ed9a9fd3e736ccc9448b2f62a94 to your computer and use it in GitHub Desktop.
Save MiCurry/6cbd4ed9a9fd3e736ccc9448b2f62a94 to your computer and use it in GitHub Desktop.
Generate a random string to std out of a specficied size
# Generates a random string of length k to std out
import argparse
import string
import random
def id_generator(size, chars=string.ascii_uppercase \
+ string.digits \
+ string.ascii_lowercase):
return ''.join(random.choice(chars) for _ in range(size))
parser = argparse.ArgumentParser(description='Generate a random string of length k')
parser.add_argument('size',
help='size',
type=int)
args = parser.parse_args()
print id_generator(size=args.size)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment