美文网首页
伪代码理解python的import

伪代码理解python的import

作者: 不懒狮Blaise | 来源:发表于2018-02-23 17:09 被阅读0次
A.py
from B import D
class C 

等于
_G["modules"]["A"] = dict()

if "B" not in _G["modules"]:
    compile B (可以当成把B.py的代码贴到这里来)
D = _G["modules"]["B"]["D"]

_G["modules"]["A"]["C"] = class

然后
A.py
import B
class C 

等于
_G["modules"]["A"] = dict()

if "B" not in _G["modules"]:
    _G["modules"]["B"] = dict()

_G["modules"]["A"]["C"] = class

------------------
B.py
from A import C
class D 

等于
_G["modules"]["B"] = dict()

if "A" not in _G["modules"]:
    compile A (可以当成把A.py的代码贴到这里来)
C = _G["modules"]["A"]["C"]

_G["modules"]["B"]["D"] = class

相关文章

网友评论

      本文标题:伪代码理解python的import

      本文链接:https://www.haomeiwen.com/subject/htixxftx.html