O'Reilly logo

Python Essentials by Steven F. Lott

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Running a script by the filename

The most common way to run a script is to provide the filename to the Python command. Let's assume we have a file with the unpleasant name of ch12_script1.py in a directory named Chapter_12.

In Linux and Mac OS X, the full name will be Chapter_12/ch12_script1.py. In Windows, the full filename will be Chapter_12\ch12_script1.py. We'll stick with the Linux standard filenames for the remaining examples.

Here's how we can run a script by giving the filename:

MacBookPro-SLott:Code slott$ python3 Chapter_12/ch12_script1.py
Temperature °C: 8
C=8°, F=46°

This output shows the OS prompt. The python3 command that we entered is highlighted. The prompts and the outputs from the script are also shown. This example is typical ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required