Couldn't find this info in the docs.. In Python, ...
# getting-started
a
Couldn't find this info in the docs.. In Python, my
__main__.py
simply imports other modules and the project contains other modules still. However, Pulumi seems to require all the
__init__.py
to import modules, or else Pulumi doesn't import them. Is this correct? I need to explicitly import all modules and packages in each package's
__init__.py
? If so, is there a better / more standardized way?
s
There is nothing special about Pulumi and the import process. Once you import main.py, it is just Python code at that point that follows standard rules for imports. I use imports regularly and my init.py files are all empty. I suspect there is something about your project setup. I would recommend the use of a tool like
pyscaffold
to set up your project -- it tends to put everything in the correct place and generally takes care of most people's import issues.
👍 1
n
Correct, this is a
python
item and not
pulumi
. If the other modules exists in other directories, then those directories must have an
___init.py___
file. This is what tells python it is a package/module.