Organizing Our Thoughts
In this chapter, you learned the following:
-
A module is a collection of functions and variables grouped together in a file. To use a module, you must first import it using import «modulename». After it has been imported, you refer to its contents using «modulename».«functionname» or «modulename».«variable».
-
Variable __name__ is created by Python and can be used to specify that some code should only run when the module is run directly and not when the module is imported.
-
Programs have to do more than just run to be useful; they have to run correctly. One way to ensure that they do is to test them, which you can do in Python using module doctest.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access