How to Call Python Files?

Learn about the different ways of calling Python files.

We'll cover the following...

There are two ways to call Python files:

  1. We can call the file directly (Python [filename]), which is what we’ve been doing.

  2. We can call the file using an external library.

We haven’t covered calling the file using an external library yet. If we wanted to use the function count_words in another file, we would do this:

from word_count import count_words

This will take the function count_words and make it available in the new file. We can also do the following:

from word_count import *

This will import all functions and variables, ...