A Complete Beginner’s Introduction to Python
Part 10
Modules
Let’s create our own module! For this we’ll need to:
- Come up with some functionality we want to encapsulate into a function.
- Save that function and any
importstatements it requires in a new file that ends with.py - Open up the Python interpreter and import that file by running
import filenamewherefilenameis the name of the file without the.pyon the end. - Run the function by entering in
filename.functioname()and entering any parameters it requires!