Indenting the same set of statements constitutes a block of code, called a code group: the first line of code group begins with a keyword, ends with a colon ":", and one or more lines after that line constitute a code group!
Module structure and layout: Here is a __doc__ document property that can access the module, or the description of the function document
1. Starting Line
2. Module documentation
3. Module Import
4. Variable definition
5. Class definition
6. Function definition
7. Main program
?
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
#/usr/bin/env python #1、Startup line"this is a test module" #2、Module documentationimport sys #3、Import Modules import osdebug = True#4、global variables declarationsclass FooClass(): #5、class declarations "Foo Class Documentation" passdef test(): #6、functions declarations foo = FooClass() if debug: print ‘ran test()‘if __name__ == "__main__": #7、main __name__属性指示模块应该如何被加载! test() |