'How can I have aliases for the a package inside a package in Python?
Suppose I have a third party package inside my Python package:
package/
mymodule
3rdparty/
othermodule
Files inside the 3rdparty package use from 3rdparty import othermodule (1).
However, I want to be able to also use import package.3rdparty.othermodule (2) from my own modules (mymodule).
How can I accomplish this? If I import the 3rd party package from mymodule using import method (2) I get a No module named: 3rdparty error when othermodule attemps to import using import method (1).
Ideally, I would not mess with the PYTHONPATH environment variable.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
