October 2018
Beginner to intermediate
466 pages
12h 2m
English
Absolute imports specify the complete path to the module, function, or class we want to import. If we need access to the Product class inside the products module, we could use any of these syntaxes to perform an absolute import:
import ecommerce.products product = ecommerce.products.Product() //orfrom ecommerce.products import Product product = Product() //orfrom ecommerce import products product = products.Product()
The import statements use the period operator to separate packages or modules.
These statements will work from any module. We could instantiate a Product class using this syntax in main.py, in the database module, or in either of the two payment modules. Indeed, assuming the packages are available to Python, ...