Python: import the containing package

后端 未结 5 1427
夕颜
夕颜 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-13 13:04

    I'm not totally sure what the situation is, but this may solve your "different name" problem:

    import __init__ as top
    top.some_function()
    

    Or maybe?:

    from __init__ import some_function
    some_function()
    

提交回复
热议问题