生活的美妙在于,不知道一下秒是惊艳还是伤神,时光流转,珍惜现在的拥有的时光
全部博文(276)
分类: Python/Ruby
2016-05-05 14:37:07
点击(此处)折叠或打开
点击(此处)折叠或打开
Modules…
Predefined (writable) attributes: __name__ is the module’s name;
… Classes…
Special attributes: __name__ is the class name;
'__main__' is the name of the scope in which top-level code executes. A module’s __name__ is set equal to '__main__' when read from standard input, a script, or from an interactive prompt.
A module can discover whether or not it is running in the main scope by checking its own __name__, which allows a common idiom for conditionally executing code in a module when it is run as a script or with python -m but not when it is imported:
For a package, the same effect can be achieved by including a __main__.py module, the contents of which will be executed when the module is run with -m.