Boilerplate of a Python script

This is a little bit of boilerplate code for a Python script.

Shebang

For Python 2:

#!/usr/bin/env python

For Python 3:

#!/usr/bin/env python3

Run the main method

import sys
import time

def method_a():
	try:
		while do_something():
			time.sleep(1)
		return True
	except KeyboardInterrupt:
		return False

if __name__ == '__main__':
	ok = False
	# Check for CLI arguments.
	# argv[0] is the script name itself
    if len(sys.argv) == 2:
		if sys.argv[1] == '-a':
			ok = method_a()
	    elif sys.argv[1] == '-b':
	        method_b()
	        ok = True
	   	else:
	    	show_usage()
	# Exit with a proper exit code
	sys.exit(0 if ok else 1)