a.py
- from b import b
- print '---------this is module a.py----------'
- def a():
- print "hello, a"
- b()
- a()
b.py
- print '----------this is module b.py----------'
- def b():
- print "hello, b"
- def c():
- print "hello, c"
- c()
- from a import a
运行 a.py,结果:
分析:
首先要去 b.py 中找到 b(), 而 b.py 中创建函数后直接就把 b 给它了,最后 b.py 又向 a.py 中要 a,因为 b.py 已经得到想要的了,就答应给 a.py 想要的。就是说,我要的你先给我了,所以我也给你你想要的
运行 b.py,结果:
分析:
a.py 先向 b.py 要 a(),但 b 不答应,反而要 a.py 先给 b(),a.py 不乐意,即使有也不给,谁让你不先满足我的要求。
总结,谁先要的必须给,如果不能被满足,就不答应另一方的要求,有点无理,但也没办法,人是自私的,程序也是自私的,否则一再谦让,说不定会让一个人即使给了东西却什么也得不到。
来源: