Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialThomas McMenemy
7,877 PointsI apologize if this was already covered, but why was Python run with the "-i"?
I apologize if this was already covered, but why was Python run with the "-i"?
2 Answers
Dave McFarland
Treehouse TeacherIn this video Craig uses the -i
flag to load a Python script into the REPL, so that he can interact with the script interactively ("i" for interactive).
If you type this python meeting_list.py
, the python script runs. When the script ends you're in the console.
However if you type python -i meeting_list.py
the file is loaded and run, but you end in the Python REPL. Then you can run any commands in the REPL -- for example to inspect the final state of a variable after the script runs.
Ken Alger
Treehouse TeacherThomas;
The -i
generic option is used to inspect global variables or a stack trace when a script raises an exception.
You can read more about it by running the python --help
command at the command line, or visiting the documentation on the Command line and environment and the PYTHONINSPECT option.
Hope it helps.
Ken