https://www.python.org/dev/peps/pep-0008/
#!/usr/bin/python # -*- coding:utf-8 -*- # @filename: pep_summary # @author:vickey wu # @date: 2017/9/5 8:45 # Start at 5th Sep 2017 # Change at 6th Sep 2017 add Class and function summary import os import sys from time import * from subprocess import Popen, PIPE from selenium.webdriver.support.wait import WebDriverWait # long content cut to two or more part with "" content = "this is a very long long long long long long long long long content long content" slice_content = content[2:10:2] print slice_content length_con = len(content) a, b, c = "", None, None if 72 < length_con <= 120: if content == "this" and length_con == 80: length_con = (length_con + length_con + length_con + length_con) print length_con # different between "is" and "==" if b is not c: print "different object" else: print "same object" if a == c: print "same value" else: print "different value" # different between "and" and "&" aa, bb, cc = 1, 2, 1 if aa == 1 and bb == 2: print "'and' is logic operation, 1 treat as decimal 1" if aa == 1 & cc == 1: print "'&' is bitwise operation, 1 treat as binary 01" else: print "different" try: aa == bb except Exception as e: print "aa is not equal to bb" # add whitespace at the lowest priorities i = aa + bb ii = (aa + bb) + aa * (bb + cc) + aa - bb # Don't use spaces around the "=" when used to indicate a keyword argument or a default parameter value def func(default_para1=1, para2=None): """ :param default_para1: :param para2: :return: """ return func(1, None) def funct(default_para1=1, para2=None): return func(1, None) class ClassA(object): """ :param object """ def __init__(self, para_a=None): self.para_b = para_a def get(self): """ None :return: """ para2 = self.para1 return para2 def _func(self): """ __ two underline in the beginning mean the goal here is to avoid your method to be overridden by a subclass :param args: :param kwargs: :return: """ return self.para_b class ClassB(ClassA): """ This Class used to practice pep8 regulation """ def __init__(self, para1=None, para2=None, para3=None): super(ClassA, self).__init__(para1, para2) self.para3 = para3 def class_func1(self): para4 = self.para1 + self.para2 if para4 is not None: return para4 def _private_func(self): """ _ one underline in the beginning mean private method or attribute, you shouldn't access it :param para_f1: :return: """ self._para_f1 = self.para1 return self._para_f1 def class_func2(self): # override class method return self.para_b def __new__(cls, *args, **kwargs): """ __ two underline in the beginning and in the end it means it's a method python calls, not you :param args: :param kwargs: :return: """ pass # name suffix or prefix with double "__" or single "_". # one underline in the beginning indicate this method or attribute is private # which mean other method can't call it. # one underline in the end avoid name is conflict with keyword. # two underline in the beginning to avoid your class method be overridden by subclass. # two underline in the beginning and in the end means it's a method python calls, not you. # Use _one_underline to mark you methods as not part of the API. Use __two_underlines__ # when you're creating objects to look like native python objects # or you wan't to customize behavior in specific situations. # And don't use __just_two_underlines, unless you really know what you're doing b = ClassB(object) a = ClassA(object) # b.