Python: import the containing package

后端 未结 5 1419
夕颜
夕颜 2020-12-13 12:00

In a module residing inside a package, i have the need to use a function defined within the __init__.py of that package. how can i import the package within the

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-13 12:59

    If the package is named testmod and your init file is therefore testmod/__init__.py and your module within the package is submod.py then from within submod.py file, you should just be able to say import testmod and use whatever you want that's defined in testmod.

提交回复
热议问题