Last active
December 24, 2015 04:49
-
-
Save andychase/6746719 to your computer and use it in GitHub Desktop.
Minimal Python command line argument processing
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 | |
""" A fairly simple way of parsing arguments without using libraries. | |
Licenced: http://creativecommons.org/publicdomain/zero/1.0/ | |
""" | |
import sys | |
def main(_=None, argument_1="", argument_2="", *args): | |
if not argument_1: | |
print("need arg 1!)" | |
# etc. | |
if __name__ == "__main__": | |
main(*sys.argv) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment