Skip to content

Instantly share code, notes, and snippets.

@dmoney dmoney/rand9999.py
Created May 26, 2018

Embed
What would you like to do?
# python 3.6+
# written for: https://dev.to/r0f1/write-a-simple-but-impactful-script-7ba
import sys, random, argparse
parser = argparse.ArgumentParser(
description='Print the numbers from 0000 to 9999 in random order.')
parser.add_argument('FILENAME',
type=str,
default=None,
nargs='?',
help="Output file (default STDOUT)")
args = parser.parse_args()
filename = args.FILENAME
with (open(filename, 'w') if filename else sys.stdout) as file:
for num in random.sample(range(10000), k=10000):
file.write(f'{num:#04d}\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.