Security scan is checking this page.

Lesson 819 of 1524

Modules

Modules often include the line if __name__ == "__main__" to prevent code from running as a side effect when the module is imported by other programs

Practice this chapter

Modules often include the line if __name__ == "__main__" to prevent code from running as a side effect when the module is imported by other programs When working in a shell, the help () function can be used to look up the documentation for a module.

The documentation is generated from the docstrings

documentation — generated from the docstrings. side effect when the module — imported by other programs.

Be able to write a module that consists only of function definitions; explain how to avoid a name collision when importing a module; identify code that will run as a side effect of importing.

Worked example

What does “documentation” mean in Modules?

  1. 1Use the wording this chapter gives for documentation.
  2. 2The book says: generated from the docstrings.
  3. 3Do not use the meaning of side effect when the module. That term means imported by other programs.

Result: generated from the docstrings

Why. That is the meaning this chapter gives for documentation.

Do not swap documentation and side effect when the module. documentation means generated from the docstrings. side effect when the module means imported by other programs.

Practice margin

This chapter

A fresh set from this chapter only. Choose 10 or 20. Multiple choice and fill-in, with no repeat inside the set.