Skip to main content Link Search Menu Expand Document (external link)

Modules

This week we’re looking at modules, which is another way to organize a Python program. In the ‘real world’, programs often consist of multiple files which work with one another. Some programs might have dozens or even hundreds of source files, all of which have code in them. The more complex a program is the longer the code will be. Breaking up a program into multiple files is a way to keep things more organized, and to make collaborating easier.

We’ve already been using modules - every time you use import, you’re using a module for Python that someone else has written, like random or turtle. Those modules contain functions that you can use in your program. This week you’ll get to write your own modules.

Readings

Summary

For the summary this week, think about past programs you’ve written and how those programs have been organized. Also think about how you’ve written programs in studios, where multiple people were working on different pieces of the same program. How might using modules have helped?

Summary prompt: Think about and describe a strategy for deciding when to break up a program into multiple files, and how to decide what goes in which file.

Question

As per usual, your question can be one of three types:

  • Confusion: what didn’t you understand in the readings?
  • Curiousity: what do you want to know more about?
  • Connection: how does this topic connect to your own experiences?

There is no class on Tuesday this week due to fall break. Submit your summary+question on D2L under Quizzes before class starts on Thursday.