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系列算法)的基础上,使用密钥对消息摘要进行加密.它相当于一个马甲,内里可 ...
随机推荐
- mysql 联合2个列的数据 然后呈现出来
SELECT a.voyageNum,CONCAT(a.startDate,'~',a.endDate) AS 日期 FROM tchw_voyageoilcost a ,tchw_voyageoi ...
- 反编译Android的apk包得到源码(使用工具:dex2jar和jd-gui)
1. 先从 http://download.csdn.net/detail/dingyuming1991/9618125 下载反编译工具dex2jar和jd-gui(当然也可以google搜索下载): ...
- 组件-实体-系统 Entiy-Compoent-System ECS架构整理
继承体系的问题,为什么要用ECS 面向对象的问题 当一个新的类型需要多个老类型的不同功能的时候,不能很好的继承出来 游戏开发后期会有非常多的类,很难维护 游戏中子系统很多,它们对一个对象的关注点往往互 ...
- poj 3525Most Distant Point from the Sea【二分+半平面交】
相当于多边形内最大圆,二分半径r,然后把每条边内收r,求是否有半平面交(即是否合法) #include<iostream> #include<cstdio> #include& ...
- poj 2187【旋转卡壳模板】
求平面最远点对 #include<iostream> #include<cstdio> #include<algorithm> #include<cmath& ...
- AOP日志框架实现
AOP日志框架实现 JDK动态代理实现日志框架 首先,在项目包com.ay.test 下创建业务接口类BusinessClassService,具体代码如下: BusinessC lassServic ...
- POJ2482 Stars in Your Window(扫描线+区间最大+区间更新)
Fleeting time does not blur my memory of you. Can it really be 4 years since I first saw you? I stil ...
- 通过IDEA制作包含Java应程序的Docker镜像
IDEA官网在IDEA中把Java App制作成Docker镜像并启动一个容器运行 在idea上使用docker作为java的开发环境[][] ubuntu+docker+docker-compose ...
- .net简单的fileupload控件上传
前台代码: <asp:FileUpload ID="FileUpload1" runat="server" /> <asp:Button ID ...
- 学习笔记 第十章 使用CSS美化表单
第10章 使用CSS美化表单 [学习重点] 正确使用各种表单控件 熟悉HTML5新增的表单控件 掌握表单属性的设置 设计易用性表单页面 10.1 表单的基本结构 表单包含多个标签,由很多控件组成 ...