- Google teaches a "class" on Python
- Running a script from the command line (IPython) can be done with %run
I ran into a hiccup working through Google’s Python Class. I came across the need to run a script with command line flags:
./wordcount.py {--count | --topcount} file
Since I’m using the Spyder IDE with the built-in IPython console, I could running this script from the command line like so:
%run wordcount.py --count alice.txt
The problem with running the script this way is that the IDE completely ignores any breakpoints I have set, so debugging isn’t possible. Alternatively, using Spyder’s “Run” button observes the breakpoints, but ignores the command line flags!
The Solution
The solution is actually pretty obvious. It involves modifying the Run Settings, as shown in the picture below.
Now, the “Run” button will consider the command line options. The script runs as desired with the ability to debug the code!