Well skip the interpreter part which i see tiny chance of using it.
Typical python module definition file which have file extension of *.py have below format.
if you have multiple version of python install in your system, you can specify which version you want your program to run with.
#below check your py.ini for defaults of "python" version #! python #below specify the encoding of this python source file. utf-8 is default. #-*-coding: utf-8-*- #then import some module you reference import numpy import sys,os def fun1(a): pass def main(): pass #below will use module file as script to run main, mainly for test purpose if __name__ == '__main__': main()
-
Use 4-space indentation, and no tabs.4 spaces are a good compromise between small indentation (allows greater nesting depth) and large indentation (easier to read). Tabs introduce confusion, and are best left out.
-
Wrap lines so that they don’t exceed 79 characters.This helps users with small displays and makes it possible to have several code files side-by-side on larger displays.
-
Use blank lines to separate functions and classes, and larger blocks of code inside functions.
-
When possible, put comments on a line of their own.
-
Use docstrings.
-
Use spaces around operators and after commas, but not directly inside bracketing constructs:
a = f(1, 2) + g(3, 4)
. -
Name your classes and functions consistently; the convention is to use
CamelCase
for classes andlower_case_with_underscores
for functions and methods. Always useself
as the name for the first method argument. -
Don’t use fancy encodings if your code is meant to be used in international environments. Python’s default, UTF-8, or even plain ASCII work best in any case.
-
Likewise, don’t use non-ASCII characters in identifiers if there is only the slightest chance people speaking a different language will read or maintain the code.
沒有留言:
張貼留言