http://python3-cookbook.readthedocs.io/zh_CN/latest/index.html

一般的类找方法,通过MRO找到第一个就停了对吧,可以描述器好像会顺着MRO把所有的方法都执行一遍

原理????

rabbitmq

http://www.rabbitmq.com/tutorials/tutorial-one-go.html

python的xlutils 组件是不是不能处理xlsx格式 的excel?

有人用过python hdfs库或者pyhdfs库么,或者对hadoop熟悉

python 多继承详解

http://www.python.com/html/2013/pythonhexinbiancheng_0828/550.html

python装饰器 == 代码装B神器

class Descriptor:

def init(self, name):

self.name = name

def __get__(self, instance, cls):
print('getting...')
if instance is None:
return self
else:
return instance.__dict__[self.name] def __set__(self, instance, value):
print("this is Descriptor.__set__")
instance.__dict__[self.name] = value def __delete__(self, instance):
raise AttributeError("Can't delete")

class Typed(Descriptor):

ty = object

def set(self, instance, value):

print("this is Typed.set")

if not isinstance(value, self.ty):

raise TypeError('Expected {}'.format(self.ty))

super().set(instance, value)

class String(Typed):

ty = str

class PosFloat(Float, Positive):

pass

class Sized(Descriptor):

def init(self, args, maxlen, **kwargs):

print("this is in Sized.init")

self.maxlen = maxlen

super().init(
args, **kwargs)

def __set__(self, instance, value):
if len(value) > self.maxlen:
raise ValueError('Too big')
super().__set__(instance, value)

class SizedString(String, Sized):

pass

import re

class Regex(Descriptor):

def init(self, args, pat, **kwargs):

print("this is in Regex.init")

self.pat = re.compile(pat)

super().init(
args, **kwargs)

def __set__(self, instance, value):
if not self.pat.match(value):
raise ValueError('Invalid string')
super().__set__(instance, value)

class SizedRegexString(String, Sized, Regex):

pass

class Stock(Structure):

_fields = ['name', 'shares', 'price']

name = SizedRegexString('name', maxlen=8, pat='[A-Z]+$')

shares = PosInteger('share')

price = PosFloat('price')

s = Stock('XX', 50, 91.1)

__init__是可以通过__super__来实现,__set__和__get__是不是自带__super__功能啊

python3-cookbook的更多相关文章

  1. Python 学习教程

    <Core Python Programming>勘误参考表 http://starship.python.net/crew/wesc/cpp/errata2.htm 笨办法学 Pytho ...

  2. 如何系统地自学 Python?

    最近开始系统的学习Python,以及整理的一些资料.github记录着个人自学 Python 的过程,持续更新.欢迎大家一起来完善这个自学Python学习的项目,给后来者一个参考的学习过程.githu ...

  3. python学习路线--从入门到入土

    入门技术博客 进阶自己挑选 入门基础 Python入门相对容易又可以干很多事(网站,运维,数据,爬虫等),是一门方便的工具语言.2016年TIOBE排名显示Python已经名列第四,成为脚本语言之首. ...

  4. 自学 Python

    如何系统地自学 Python?   最近开始系统的学习Python,以及整理的一些资料.github记录着个人自学 Python 的过程,持续更新.欢迎大家一起来完善这个自学Python学习的项目,给 ...

  5. 最全数据分析资料汇总(含python、爬虫、数据库、大数据、tableau、统计学等)

    一.Python基础 Python简明教程(Python3) Python3.7.4官方中文文档 Python标准库中文版 廖雪峰 Python 3 中文教程 Python 3.3 官方教程中文版 P ...

  6. 计算机电子书 2016 BiliDrive 备份

    下载方式 根据你的操作系统下载不同的 BiliDrive 二进制. 执行: bilidrive download <link> 链接 文档 链接 Go入门指南.epub (1.87 MB) ...

  7. 我与python3擦肩而过(二)—— csv文件头哪去啦?

    在看Python Data Visualization Cookbook 这本书(基于python2),开始时读取csv文件头的时候出现问题.查了资料,又是python3的问题,从这个链接找到答案. ...

  8. 学python3的书

    <Python Cookbook>3rd Edition http://python3-cookbook.readthedocs.io/zh_CN/latest/copyright.htm ...

  9. python2和python3的区别——持续更新

    1.在 cookbook 上看到的,python3支持 *运算符 来接收迭代变量,如: a, *b = [, , , ] python2是不支持的! 2.在 cookbook 上看到的,python3 ...

  10. Python3 系列之 并行编程

    进程和线程 进程是程序运行的实例.一个进程里面可以包含多个线程,因此同一进程下的多个线程之间可以共享线程内的所有资源,它是操作系统动态运行的基本单元:每一个线程是进程下的一个实例,可以动态调度和独立运 ...

随机推荐

  1. js 获取地址栏参数

    function GetQueryString(name) { var reg = new RegExp("(^|&)" + name + "=([^&] ...

  2. bootstrap 固定底部导航自适应

    在使用bootstrap 底部导航的时候遇到了一个问题 -- 当我的内容超过一屏的时候,底部的部分内容会被固定的导航内容遮盖 自己写了一个JS脚本,解决自适应的问题 <nav class=&qu ...

  3. Twsited异步网络框架

    Twisted是一个事件驱动的网络框架,其中包含了诸多功能,例如:网络协议.线程.数据库管理.网络操作.电子邮件等. Twisted介绍:http://blog.csdn.net/hanhuili/a ...

  4. javascript实现kruskal算法

    <script> //图的构建 function vnode() { this.visited = 0; this.vertex = 0; this.arcs = new Array(); ...

  5. 递归遍历多维数组(树数据结构)的超级简单方式,并且可以递归超过200层,摘自<<PHP精粹:编写高效PHP代码>>

    <?php $array = array( "Hello", // Level 1 array( "World" // Level 2 ), array( ...

  6. MySQL DBA的个人修养

    做为一个MySQL DBA,必须具有以下的素质: 一, 身体素质 DBA必须接收和处理各种报警,不论是中午在吃饭或者凌晨三点已经进入深度睡眠.接到报警需要立即进入应急状态,找到电脑,联上网络,快速定位 ...

  7. Linux体系结构(五): 文件系统

    上一节主要对Linux系统中的内核空间与用户空间做了简单的分析,在这一节里,将从内核空间和用户空间对Linux文件系统进行一定的剖析. 谈及文件系统,很多Linux用户都会有一个比较模糊和神秘的概念, ...

  8. 如何用ABBYY把PDF转换成PPT

    在电子科技迅速发展的今天,文件格式转换并不是什么稀罕事,因为现在都是电子化办公,出现很多文件格式,但是不同的场合需要的格式不同,所以常常需要进行文件格式的转换.PDF转换成PPT也是众多文件格式转换中 ...

  9. 二十四种设计模式:外观模式(Facade Pattern)

    外观模式(Facade Pattern) 介绍为子系统中的一组接口提供一个一致的界面,Facade模式定义了一个高层接口,这个接口使得这一子系统更加容易使用.示例有一个Message实体类,某对象对它 ...

  10. A javascript library providing cross-browser, cross-site messaging/method invocation. http://easyxdm.net

    easyXDM - easy Cross-Domain Messaging easyXDM is a Javascript library that enables you as a develope ...