PyPython · Lesson 6 of 14
Modules & Packages
Python's standard library is enormous. And if that's not enough, there's PyPI with 500,000+ packages. You will rarely need to write code from scratch.
A module is just a Python file. You can import any module using the import keyword, and access its contents with dot notation. The standard library covers math, dates, files, networking, JSON, and much more.
Write your own module by creating a .py file. Import it by filename (without .py). Use pip to install third-party packages from PyPI.
◆ Note
Always use a virtual environment for projects. Without one, pip installs packages globally and you'll eventually hit version conflicts. It's two extra commands and will save you hours of pain.
Always use a virtual environment for projects. Without one, pip installs packages globally and you'll eventually hit version conflicts. It's two extra commands and will save you hours of pain.