Feb. 12, 2017
12:22 a.m.
Does anyone use this pattern?: (a) accept command line parameters if __name__ == "__main__" or (b) run unittests if no parameters passed Something like: if __name__ == "__main__": if len(sys.argv)==7: command_line() else: unittest.main() I'm using this pattern with my classes, as a way of touching on both passing arguments from the command line (with nod to argparse for POSIX compliance), and self-contained testing. Maybe this would be better with doctest instead. I could do another version.... Example: https://github.com/4dsolutions/Python5/blob/master/tetravolume.py Kirby