Created
February 16, 2019 17:47
-
-
Save TylerJWhit/9c1e0bd0a022b50603b033986470ca05 to your computer and use it in GitHub Desktop.
Test argparse
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
import argparse | |
parser = argparse.ArgumentParser(description = 'Process strings') | |
parser.add_argument('-u', '--uppercase', action = 'store_true', default = False) | |
parser.add_argument('-l', '--lowercase', action = 'store_true', default = False) | |
parser.add_argument('-t', '--text', type=str) | |
args = parser.parse_args() | |
def case_function(__out__): | |
if args.lowercase == args.uppercase == True: | |
print("uppercase and lowercase switches cannot be used in tandem") | |
elif args.lowercase == args.uppercase == False or args.lowercase: | |
print(__out__.lower()) | |
else: | |
print(__out__.upper()) | |
case_function(args.text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment