0

Is there a difference between these 3 methods to import a module in the __init__.py file of a package?
Assuming that the module.py and the __init__.py are in the same directory and I am importing the package in my program as import package


import package.module
from package import module
from . import module

I did all of them and apparently, all worked with the same results.

  • 1
    Does this answer your question? [Use 'import module' or 'from module import'?](https://stackoverflow.com/questions/710551/use-import-module-or-from-module-import) – Tzane Feb 14 '23 at 07:54
  • 1
    @Tzane No, it was about importing modules in the main program but mine is about importing the modules in the _\_\_init.py\_\__ of a package. – pouria forghani Feb 14 '23 at 08:13
  • Import statements work exactly the same in module files and \_\_init\_\_.py files – Tzane Feb 14 '23 at 08:31
  • @Tzane Thank you, but I did not find my answer in the mentioned question, since my question is specifically about packages. – pouria forghani Feb 14 '23 at 12:49

0 Answers0