Last active
December 22, 2015 23:29
-
-
Save rgbkrk/6546847 to your computer and use it in GitHub Desktop.
Super duper arrow printing app. Webscale.
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
''' | |
Super duper arrow printing app, inspired by | |
http://stackoverflow.com/questions/18778266/image-making-in-python | |
Example run: | |
$ ./super_arrow.py 1 2 3 0 -1 -213 123 9 | |
↑↑↑ ↓↓↑↑ | |
''' | |
up = "↑" | |
down = "↓" | |
import argparse | |
import sys | |
if __name__ == "__main__": | |
parser = argparse.ArgumentParser(description='Arrows for integers') | |
parser.add_argument('integers', metavar='N', type=int, nargs='+', | |
help='Enter some integers') | |
args = parser.parse_args() | |
for num in args.integers: | |
if num > 0: | |
sys.stdout.write(up) | |
elif num < 0: | |
sys.stdout.write(down) | |
else: | |
sys.stdout.write(" ") | |
print("") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example: