1. Pyroom
  2. Tutorials
  3. Pro Mode
  4. Build a two-file Python project with imports

Build a two-file Python project with imports

Bigger programs are easier to read when they are split into modules. Pro Mode lets one file import functions from another.

Intermediate Video coming soon. The steps below show everything the video will cover.

Steps

  1. Start in Pro Mode, from Settings, Mode.
  2. Select New file and name it helpers.py.
  3. Write a small function in helpers.py.
  4. Open main.py. Import the function with from helpers import greet, then call it.
  5. Run starts main.py, the entry file, and the import just works.
Read the transcript

Start in Pro Mode, from Settings, Mode.

Select New file and name it helpers.py.

Write a small function in helpers.py.

Open main.py. Import the function with from helpers import greet, then call it.

Run starts main.py, the entry file, and the import just works.

Try it in the Playground

Nothing to install and no account needed.

Open Playground →