Python Programming - Running Python

Python Programming – Running Python

Also Read: Graph Theory Questions and Answers

Running Python

There are three different ways to start Python:

  • Interactive Interpreter
  • Script from the Command Line
  • Integrated Development Environment

Interactive Interpreter

You can start Python from DOS, Unix, or any other system that provides you a command-line interpreter or shell window. Enter python at the command line, which opens python interpreter as displayed in Fig. 1.3. It displays information about the Python version, i.e, 3.5.1., the date it was released, and a few options of what can be pursued next.

Python Programming - Running Python chapter 1 img 1

Here is the list of all the available command-line options in Table 1.1.:

Option Description
-d provide debug output
-o generate optimized bytecode (resulting in .pyo files)
-s do not run import site to look for Python paths on startup
-V verbose output (detailed trace on import statements)
-X disable class-based built-in exceptions (just use strings); obsolete starting with version 1.6
-c cmd run Python script sent in as cmd string
File run Python script from given file

Script from the Command-line

A Python script can be executed at the command line also. This can be done by invoking the interpreter on your application, as displayed below:

$python script.py #Unix/Linux
or
python % script.py #Unix/Linux
or
c:>python script.py #Windows/DOS

Integrated Development Environment

Python can be run from a Graphical User Interface (GUI) environment as well if you have a GUI application on your system that supports Python.

  • Unix: IDLE is the very first Unix IDE for Python.
  • Windows: PythonWin is the first Windows interface for Python.
  • Macintosh: The Macintosh version of Python is available from the main website along with the IDLE IDE, downloadable as either MacBinary.

Python Tutorial

Leave a Reply

Your email address will not be published. Required fields are marked *