I want to import a function from another file in the same directory. 我想从同一目录中的另外一个文件导入函数。 dom
Sometimes it works for me with from .mymodule import myfunction
but sometimes I get a: 有时它与from .mymodule import myfunction
对我from .mymodule import myfunction
但有时我获得: ide
SystemError: Parent module '' not loaded, cannot perform relative import
Sometimes it works with from mymodule import myfunction
, but sometimes I also get a: 有时它与from mymodule import myfunction
,但有时我也获得: 函数
SystemError: Parent module '' not loaded, cannot perform relative import
I don't understand the logic here, and I couldn't find any explanation. 我不了解这里的逻辑,也找不到任何解释。 This looks completely random. 这看起来彻底是随机的。 this
Could someone explain to me what's the logic behind all this? 有人能够向我解释全部这些背后的逻辑是什么? spa