Get startedGet started for free

Sibling imports

The module you documented in the last exercise, impyrial, is growing and you have separated the private functions (the ones you don't really want your users to use) from your public functions. The private functions are in the core.py module and the public ones are in the api.py module.

However, you need to use the private functions to make the public functions work. In this exercise, you will import them into the api.py module to get your package modules working together.

Note: Please make sure that you run the example_script.py. If you run the api.py file, you get an ModuleNotFoundError: No module named 'impyrial' as is expected.

Remember that you can open/close the folder and files overview by clicking on the icon on the left side of the editor highlighted in red. Icon with multiple files

This exercise is part of the course

Developing Python Packages

View Course

Exercise instructions

  • Import the functions inches_to_feet() and inches_to_yards(), and the variable UNITS from the impyrial/length/core.py module into impyrial/length/api.py. Use an absolute import.
  • Import the function convert_unit() function in impyrial/length/api.py into the example_script.py script. You'll need to import this using the full filepath to the api module.
  • Run the example_script.py to check that your imports work.

Hands-on interactive exercise

Turn theory into action with one of our interactive exercises

Start Exercise