Next / Previous / Contents / TCC Help System / NM Tech homepage

3.2. Using Python in Linux

To enter conversational mode on a Linux system, type this command:

python

Type Control-D to terminate the session.

If you write a Python script named filename.py, you can execute it using the command

python filename.py

Under Unix, you can also make a script self-executing by placing this line at the top:

#!/usr/bin/env python

You must also tell Linux that the file is executable by using the command “chmod +x filename”. For example, if your script is called hello.py, you would type this command:

chmod +x hello.py