For example we can use
oslo_db to replace
oslo.db to import (see the first comment on this patch set:
from oslo.db import exception as db_exc
YAMAMOTO Takashi: oslo_db
And I can't find the
oslo_db module in the OpenStack git repo or search for it in pip.
What's more, I boot a VM and find that it's ok to use
oslo.db since I only installed
import oslo_db example and I only installed
I have seen a article about this, but sorry that I have forget it.
Best How To :
You can't just use
_ to replace the
. separator. Not without additional effort by the module authors.
For any module that you can, there is an actual extra module with the name with an underscore importing the packaged namespace.
oslo GitHub package for example, where you'll find two top-level directories, each with a
__init__.py file to make them packages:
This is almost invariably done to transition from one style to the other, and allowing both versions makes the transition easier. In this case it appears the developers are moving away from the
oslo.db nested namespace; the changelog for 1.4.0 includes the entry:
- Move files out of the namespace package
and the commit message states:
Move the public API out of oslo.db to oslo_db. Retain the ability to import from the old namespace package for backwards compatibility for this release cycle.
The linked Launchpad Blueprint is no longer available so you'll have to ask the OpenStack community as to why they did this.
Python project names do not have to correspond with the packages and modules that they contain. For example, the BeautifulSoup project packages their
bs4 module as
beautifulsoup4. As such the
oslo_db package is part of the
oslo.db Python project.