Skip to content

Instantly share code, notes, and snippets.

@dmoney
Created May 26, 2018 04:00
Show Gist options
  • Save dmoney/1de8f451f58b899ce5650d37c22da2be to your computer and use it in GitHub Desktop.
Save dmoney/1de8f451f58b899ce5650d37c22da2be to your computer and use it in GitHub Desktop.
# 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