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