作者RUReady2 (Are you ready,too?)
看板Python
标题Re: [问题] __name__的使用时机?
时间Wed Jun 24 14:15:06 2009
l大给的网页讲得有点模糊
Knowing this, you can design a test suite for your module within the module
itself by putting it in this if statement.
这句话让我不太懂放了这个statement对於我的模组做出什麽样的testing
This makes it easier to develop and debug new modules before integrating them into a larger
program.
结论看得懂 但不知道为什麽会有这个结论
还是不太懂if __name__=='__main__'的用意
不知道版友能不能帮不才的小弟解释一下?
谢谢
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 118.167.24.92
※ 编辑: RUReady2 来自: 118.167.24.92 (06/24 14:15)
2F:推 godfat:就是说,单独执行时你的程式名称是 __main__, 反之是原名 06/24 14:27
3F:→ godfat:你可以写成单独执行时跑 test suite, 反之是一般模组 06/24 14:28
4F:→ RUReady2:g大讲的第二句看不懂 可以请g大举个例吗? 06/24 14:34
5F:推 kstar:有喔 06/24 14:35
6F:→ RUReady2:第三段後两行看不懂... 06/24 14:38