1 of 8

Modules in Python

2 of 8

What are Modules?

  • Modules are files containing Python definitions and statements (ex. name.py)
  • A module’s definitions can be imported into other modules by using “import name
  • The module’s name is available as a global variable value
  • To access a module’s functions, type “name.function()”

3 of 8

Package in Python

  • Python modules may contain several classes, functions, variables, etc. whereas Python packages contain several modules.

  • In simpler terms, Package in Python is a folder that contains various modules as files.

4 of 8

5 of 8

6 of 8

7 of 8

8 of 8

Importing * From a Package

  • * does not import all submodules from a package
  • import sound.effects.echo

import sound.effects.surround

from sound.effects import *