The format specified by the python module is the most standard.
The code structure of a python module is generally written in the following format. Refer!
#1) start line
#! /Usr/bin/env python
#-*-Codeing: UTF-8 -*-
#2) module documentation
"Show off features of [pydoc] module
This is a silly module
Demonstrate docstrings
"""
#3) module information
_ Author _ = 'python'
_ Version __= '1. 0'
_ Nonsense _ = 'aaaabbbbccc'
#4) import module
Import sys
Import OS
#5) global variables
Debug = true
#6) Class Definition
Class MyClass (object ):
"Demonstrate class docstrings """
Def _ init _ (self, spam = 1, eggs = 2 ):
"Set default attribute values only
Keyword arguments:
Spam-a processed meat product
Eggs-a fine breakfast for lumberjacks
"""
Self. spam = spam
Self. eggs = eggs
If debug:
Print 'ran _ init __(...)'
#7) Function Definition
Def test ():
"Test function"
Myclass = MyClass ()
If debug:
Print 'ran test (...)'
#8) main program Definition
If _ name _ = '_ main __':
Test ()