pep8摘要
https://www.python.org/dev/peps/pep-0008/
#!/usr/bin/python
# -*- coding:utf- -*- # @filename: pep_summary
# @author:vickey wu
# @date: // : # Start at 5th Sep
# Change at 6th Sep 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[::]
print slice_content
length_con = len(content)
a, b, c = "", None, None if < length_con <= :
if content == "this" and length_con == :
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 = , ,
if aa == and bb == :
print "'and' is logic operation, 1 treat as decimal 1"
if aa == & cc == :
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=, para2=None):
"""
:param default_para1:
:param para2:
:return:
"""
return func(, None) def funct(default_para1=, para2=None):
return func(, 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.
pep8摘要的更多相关文章
- python代码风格指南:pep8 中文翻译
摘要 本文给出主Python版本标准库的编码约定.CPython的C代码风格参见PEP7.本文和PEP 257 文档字符串标准改编自Guido最初的<Python Style Guide&g ...
- java根据html生成摘要
转自:http://java.freesion.com/article/48772295755/ 开发一个系统,需要用到这个,根据html生成你指定多少位的摘要 package com.chendao ...
- Atitit HTTP 认证机制基本验证 (Basic Authentication) 和摘要验证 (Digest Authentication)attilax总结
Atitit HTTP认证机制基本验证 (Basic Authentication) 和摘要验证 (Digest Authentication)attilax总结 1.1. 最广泛使用的是基本验证 ( ...
- 2、摘要函数——MD2/MD4/MD5数字签名
摘要是用来防止数据被私自改动的方法,其中用到的函数叫做摘要函数.这些函数的输入可以是任意大小的信息,但是输出是大小固定的摘要.摘要有个重要的特性:如果改变了输入信息的任何内容,即使改变一位,输出也将发 ...
- 前端学HTTP之摘要认证
前面的话 上一篇介绍的基本认证便捷灵活,但极不安全.用户名和密码都是以明文形式传送的,也没有采取任何措施防止对报文的篡改.安全使用基本认证的唯一方式就是将其与SSL配合使用 摘要认证与基本认证兼容,但 ...
- Java 消息摘要 散列 MD5 SHA
package xxx.common.util; import java.math.BigInteger; import java.security.MessageDigest; import jav ...
- rpm查询命令摘要
任务 命令 显示软件包的相关信息 rpm -q -i NAME 列出软件包中含有的所有文件 rpm -q -i NAME 列出软件包中含有的配置文件 rpm -q -c NAME 列出软件包中含有的文 ...
- [Java 安全]消息摘要与数字签名
消息摘要 算法简述 定义 它是一个唯一对应一个消息或文本的固定长度的值,它由一个单向Hash加密函数对消息进行作用而产生.如果消息在途中改变了,则接收者通过对收到消息的新产生的摘要与原摘要比较,就可知 ...
- HMAC加密的消息摘要码
HMAC(Hash Message Authentication Code)哈希消息授权码,它在消息摘要算法(例如MD5,SHA系列算法)的基础上,使用密钥对消息摘要进行加密.它相当于一个马甲,内里可 ...
随机推荐
- SDK介绍
软件开发工具包(外语首字母缩写:SDK.外语全称:Software Development Kit)一般都是一些软件工程师为特定的软件包.软件框架.硬件平台.操作系统等建立应用软件时的开发工具的集合. ...
- MFC绘图
//20171/121 两点一线 比如鼠标左击和鼠标弹起的两个消息 然后响应从而获取一条线2 添加响应函数方法 类图->右击->addwindowsmessage3 Dview和main中 ...
- 476. Number Complement(补数)
Given a positive integer, output its complement number. The complement strategy is to flip the bits ...
- PCB 合拼遍历(全排序+旋转90度) 基本遍历方法
分享一下PCB合拼的组合的遍历方法,在分享之前先纠正一下 PCB拼板之多款矩形排样算法实现--学习 时间复杂度计算错误 一.PCB 合拼(全排序+旋转90度)的时间复杂度是多少? 二.合拼遍历(全 ...
- svn报错:privious operation has not finshed;run 'cleanup' if it was interrupted
在更新svn的过程中,可能中途会取消,取消之后再次更新时可能提示,如下图: 下载sqlite3工具,进入此下载地址:https://www.sqlite.org/download.html 将sqli ...
- bnu oj 13288 Bi-shoe and Phi-shoe
题目链接: http://www.bnuoj.com/contest/problem_show.php?pid=13288 题目大意: 给出一个n,然后给出n个幸运数([1,m]中不能被m整除的数的数 ...
- java数组实现买彩票(通过标识符进行判断的思想)
package com.wh.shuzu; import java.util.Random; import java.util.Scanner; /** * 买彩票 * @author 王拥江同学 * ...
- 窗口Dialog
Dialog是窗口的意思,它是Window的子类.与frame相比,frame是我们大的窗口,而dialog便是那种弹出来和你说话的对话框. Dialog类的默认布局是BorderLayout Dia ...
- 442 Find All Duplicates in an Array 数组中重复的数据
给定一个整数数组 a,其中1 ≤ a[i] ≤ n (n为数组长度), 其中有些元素出现两次而其他元素出现一次.找到所有出现两次的元素.你可以不用到任何额外空间并在O(n)时间复杂度内解决这个问题吗? ...
- 对于JS == 运算的一些理解
声明:本文是摘自一篇文章,放在这只为做为一个笔记能更好学习. 大家知道,==是JavaScript中比较复杂的一个运算符.它的运算规则奇怪,容易让人犯错,从而成为JavaScript中“最糟糕的特性” ...