Intro Python: 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.

About The Course

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.

This Course Will Show You How To...

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

Preview The Course

Why from import is bad

sys.modules

Course Contents

Course Length

4.9 Hours

Number of Lessons

52

Training Materials

10 PDFs

Coding Exercises

17

  • Introduction and welcome (2 mins)
  • What are modules? (7 mins)
  • Basic importing (7 mins)
  • sys.path (5 mins)
  • import … as (4 mins)
  • from … import (5 mins)
  • Why from … import * is bad (5 mins)
  • Python’s standard library (5 mins)
  • Exercises 1 (3 mins)
  • Exercises 1 solutions (7 mins)
  • The simplist module (7 mins)
  • Globals, attributes, and reloading (6 mins)
  • sys.modules (5 mins)
  • Docstrings (6 mins)
  • Modules are executed when imported (5 mins)
  • __name__and”__main__” (5 mins)
  • Using __name__and”__main__” (5 mins)
  • Mutual imports and __name__ (6 mins)
  • Warnings with names (3 mins)
  • Exercises 2 (3 mins)
  • Exercises 2 solutions (8 mins)
  • Intro to PyPI (9 mins)
  • Installing packages with pip (8 mins)
  • Trusting PyPI code (5 mins)
  • awesome-python.com (4 mins)
  • Installing into your own directory (3 mins)
  • Versions and upgrading (4 mins)
  •  Exercises 3 (2 mins)
  • Exercises 3 solutions (3 mins)
  • Intro to virtual environments (6 mins)
  • Creating virtual environments (5 mins)
  • Activating and detecting venvs ( 8 mins)
  • Generating and using requirements.txt file (5 mins)
  • Exercises 4 (3 mins)
  • Exercises 4 solutions (6 mins)
  • Packages (8 mins)
  • More complex package hierarchies (7 mins)
  • __init__.py files (5 mins)
  • Hierarchies and relative imports (13 mins)
  • Exercises 5 (2 mins)
  • Exercises 5 solutions (6 mins)
  • sys.modules (8 mins)
  • __all__ (5 mins)
  • .pyc files (9 mins)
  • Defined dunder names in modules and packages (6 mins)
  • Packages vs. distributions (5 mins)
  • Installing manually with setup.py files (7 mins)
  • wheelfiles (9 mins)
  • Introduction to Poetry (6 mins)
  • Creating a distribution (10 mins)
  • Publishing to PyPI (5 mins)
  • Dependencies with Poetry (8 mins)
  • Conclusion (2 mins)

This Course Is Perfect For...

If you're a Python developer who knows how to "import" a module but doesn't know how or why it works, or how to write your own modules, then this course is for you!

GET STARTED NOW

Monthly

Annual

Save 20%

BUY THIS COURSE

One-Time Purchase (Lifetime Access)
$ 180 One-Time
  • Importing modules
  • Writing modules
  • Working with packages from PyPI

OR

GET A MEMBERSHIP

Access All My Training
$ 40 Per Month
  • All my Python courses
  • Monthly office hours + special events
  • Private forum

BUY THIS COURSE

One-Time Purchase (Lifetime Access)
$ 180 One-Time
  • Importing modules
  • Writing modules
  • Working with modules from PyPI

OR

GET A MEMBERSHIP

Access All My Training
$ 400 Per Year
  • All my Python courses
  • Monthly office hours + special events
  • Private forum

100% Money Back Guarantee

I’m a one-person company dedicated to improving your career via Python and related technologies. If you haven’t gotten value from any of my courses, then just tell me — and I’ll refund your money.

Meet Your Instructor

Reuven is a full-time Python trainer. In a given year, he teaches courses at companies in the United States, Europe, Israel, India, and China — as well as to people around the world, via his online courses.

Reuven created one of the first 100 Web sites in the world just after graduating from MIT’s computer science department. He opened Lerner Consulting in 1995, and has been offering training services since 1996.

In 2020, Reuven published “Python Workout,” a collection of Python exercises with extensive explanations, published by Manning. He’s currently finishing edits on “Pandas Workout,” a similar collection of exercises using the “Pandas” library for data analytics.

Reuven’s free, weekly “Better developers” newsletter, about Python and software engineering, is read by more than 30,000 developers around the globe. His “Trainer weekly” newsletter is popular among people who give corporate training.

Reuven’s most recent venture is Bamboo Weekly: Every Wednesday, he presents a problem based on current events, using a public data set. And every Thursday, he shared detailed solutions to those problems using Pandas.

Reuven’s monthly column appeared in Linux Journal from 1996 until the magazine’s demise in 2019. He was also a panelist on both the Business of Freelancing and Freelancers Show podcasts.

Reuven has a bachelor’s degree in computer science and engineering from MIT, and a PhD in learning sciences from Northwestern University. He lives in Modi’in, Israel with his wife and three children.