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