Running a script from the command line

When you run a Python script from the command line of your shell or Terminal program, it behaves like other programs you run from the command line—when it's finished running, you get another command prompt. To run a script from the command line (indicated by the command prompt %), type python and the name of the script, like this:

% python script.py

If you run a script from the command line, you use the -i modifier to tell Python to go into interactive mode after you run it. To create a script and run it interactively on a command line, follow these steps:

Was this article helpful?

0 0

Post a comment