Created
November 14, 2017 00:56
-
-
Save MiCurry/6cbd4ed9a9fd3e736ccc9448b2f62a94 to your computer and use it in GitHub Desktop.
Generate a random string to std out of a specficied size
This file contains 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
# 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