Often I want to profile a CLI program built with Click, but I can't figure out how to parse both the Python command line options and the click command line options/arguments. For example, if my script took a single option and two arguments, I can run it fine like:
python add.py --verbose 1 2
Similarly, when I profile a simple (non-Click) script, I can do this:
python -m cProfile -o stats.txt add_no_click.py 1 2
but when I want to profile the Click script, I get this:
python -m cProfile -o stats.txt add.py --verbose 1 2
Error: no such option: -o
I know I must be missing some documentation out there. For what it's worth, I'm using Python 2.7 on Windows 10 64-bit, although I doubt it has a bearing on the answer.
python -m cProfile [-o output_file] [-s sort_order] myscript.pycProfile docs