python推荐的模块结构

(1)起始行

(2)模块文档

(3)模块导入

(4)(全局)变量定义

(5)类定义

(6)函数定义

(7)主程序

===============================

#/usr/bin/env python

"this is a test module"

 

import sys

import os

 

debug = True

 

class FooClass(object) :

>> "Foo class"

>> pass

 

def test():

>> "test function"

>> foo = FooClass()

>> if debug:

>> >> print : 'ran test()'

 

if __name__ == "__main__":

>> test()

 

 

posted on 2011-03-13 16:30  真阿当  阅读(98)  评论(0编辑  收藏  举报