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. 多线程问题(JVM重排序)

    public class Test3 { private static boolean ready; private static int Number; private static class R ...

  2. iOS应用日志:开始编写日志组件与异常日志

    应用日志(一):开始编写日志组件 对于那些做后端开发的工程师来说,看 LOG解Bug应该是理所当然的事,但我接触到的移动应用开发的工程师里面,很多人并没有这个意识,查Bug时总是一遍一遍的试图重现,试 ...

  3. 最短路--floyd算法模板

    floyd算法是求所有点之间的最短路的,复杂度O(n3)代码简单是最大特色 #include<stdio.h> #include<string.h> ; const int I ...

  4. 【NOIP2013】货车运输

    感觉这题挺水的……真的挺水的…… 原题: A 国有 n 座城市,编号从 1 到 n,城市之间有 m 条双向道路.每一条道路对车辆都有重量限制,简称限重.现在有 q 辆货车在运输货物,司机们想知道每辆车 ...

  5. java基础之:匿名内部类

    在java提高篇-----详解内部类中对匿名内部类做了一个简单的介绍,但是内部类还存在很多其他细节问题,所以就衍生出这篇博客.在这篇博客中你可以 了解到匿名内部类的使用.匿名内部类要注意的事项.如何初 ...

  6. ps调整图层

    自然饱和度:自然饱和度命令和色相饱和度命令里的饱和度相比最大的区别是自然饱和度只增加未达到饱和的颜色的饱和度,而饱和度命令则增加整个图像的饱和度,可能会导致图像颜色过于饱和,而自然饱和度不会出现这种问 ...

  7. java Pattern

    public class Test{ //匹配替换掉order by之后的字符串 public static void main(String[] args) { Pattern pattern = ...

  8. MSSQL中建立分区表(转载备忘)

    转载自CSDN地址:http://bbs.csdn.net/topics/330087045 SQL Server 2005 分区表实践——建立分区表(partition table) 问题:有一个订 ...

  9. Q7: Unique Binary Search Trees

    问题描述: Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For ...

  10. 关于c语言char类型输入输出的一个bug

    题目 输入一个整数n,接下来n行每一行输入两个用一个空格分隔的字符. 对每一对字符,比较其大小关系并输出比较的结果:1.0.-1. 解决的代码如下: #include<stdio.h> i ...