Tutorial by Examples

A module is a single Python file that can be imported. Using a module looks like this: module.py def hi(): print("Hello world!") my_script.py import module module.hi() in an interpreter >>> from module import hi >>> hi() # Hello world!
A package is made up of multiple Python files (or modules), and can even include libraries written in C or C++. Instead of being a single file, it is an entire folder structure which might look like this: Folder package __init__.py dog.py hi.py __init__.py from package.dog import woof fro...

Page 1 of 1