LernerPython

Modules and packages

Python’s modules make it easy to reuse code. This course explains how to use modules, as well as how to write them, and how to integrate third-party modules from the Internet into your work.

What you should know

Course Content

Course length

5 hours

Number of lessons

52

Training materials

10 PDFs + Jupyter notebooks

Coding exercises

17

LEARN MORE

One of the amazing things about Python is how quickly you can get started writing code. Within a few days or weeks, you can be writing useful, sophisticated applications that solve real business problems.

But then you’re faced with a different sort of problem: How do you organize your code, so that it’s easier to understand, reuse, and debug?

Most programming languages offer libraries, and Python is no different. We call them “modules,” and they offer us not only the chance to keep reusable code in separate, loadable files, but also to separate our variables into namespaces. Knowing how to use modules, how the module-loading system works, how to write modules, and how to use third-party modules on the Internet are all part of being a modern Python developer.

In this course, I teach you how to use modules in your day-to-day work: We see how to import them (including the different forms of “input”), how to write them, and how to download them from PyPI using pip. We even go through a number of useful modules in the Python standard library, so that you can get a better idea of what’s available and how to use it.

We also discuss virtual environments, a common technique to ensure that package installations from one project don’t interfere with another.

If you program in Python and don’t yet have a robust understanding of how to use, write, and distribute modules, then this course is for you.

  • How to import modules using all of the different forms of the “import” statement
  • The Python standard library, and what it includes
  • How to write modules
  • Downloading and installing packages from PyPI with pip
  • How Python loads modules
  • What __name__ and ‘__main__’ do and mean, and how to use them
  • The differences between modules and packages
  • Using virtual environments (venvs) with Python projects

As with all courses on LernerPython, the instructor is Reuven Lerner.