Skip to content

Instantly share code, notes, and snippets.

@4e1e0603
Created December 17, 2017 16:04
Show Gist options
  • Save 4e1e0603/a082ffcf430413c019317948a7a212a9 to your computer and use it in GitHub Desktop.
Save 4e1e0603/a082ffcf430413c019317948a7a212a9 to your computer and use it in GitHub Desktop.
Generate UUIDs
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Script for generating unique IDs for persons.
The script accepts command line arguments stating how many IDs should be generated,
if the number of IDs is not defined or it is not a number, the script will generate
default number of IDs (which is set to 10000).
"""
import uuid
import sys
default_ids = 10000
sys_args = sys.argv
if len(sys_args) == 2:
try:
sys_args[1] = int(sys_args[1])
except ValueError as err:
print("Command line argument was not converted to integer. ", err,
"\nUsing default number of IDs to generate")
sys_args[1] = default_ids
else:
sys_args.append(default_ids)
for i in range(int(sys_args[1])):
print(uuid.uuid4())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment