Skip to content

Files

Latest commit

 

History

History
 
 

15 - Packages

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

Packages and modules

Modules

Modules allow you to store reusable blocks of code, such as functions, in separate files. They're referenced by using the import statement.

# import module as namespace
import helpers
helpers.display('Not a warning')

# import all into current namespace
from helpers import *
display('Not a warning')

# import specific items into current namespace
from helpers import display
display('Not a warning')

Packages

Distribution packages are external archive files which contain resources such as classes and functions. Most every application you create will make use of one or more packages. Imports from packages follow the same syntax as modules you've created. The Python Package index contains a full list of packages you can install using pip.

Virtual environments

Virtual environments allow you to install packages into an isolated folder. This allows you to better manage versions.