Both are the same. If you look at the docs or at the source code you will see that openpyxl package is organised in sub-packages. One of these sub-packages is
So using
At the same time the __init__.py file for top-level openpyxl package
imports the load_workbook() effectively exposing it and makes it possible to use
It's perfectly fine to use any of these - do as you prefer.
openpyxl.reader
. in sub-package openpyxl.reader
there is module excel.py
and load_workbook()
function is part of this module.So using
from openpyxl.reader.excel import load_workbook
is very explicit from where you import it.At the same time the __init__.py file for top-level openpyxl package
imports the load_workbook() effectively exposing it and makes it possible to use
from openpyxl import load_workbook
or if you do just import openpyxl
to use wb = openpyxl.load_workbook(some_file)
It's perfectly fine to use any of these - do as you prefer.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs