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. 《灰帽Python-黑客和逆向工程师的Python编程》学习记录

    ctypes是Python语言的一个外部库,提供和C语言兼容的数据类型,可以很方便的调用C DLL中的函数. 操作环境:CentOS6.5 Python版本:2.66 ctypes是强大的,强大到本书 ...

  2. sql server ,OVER(PARTITION BY)函数用法,开窗函数,over子句,over开窗函数

    https://technet.microsoft.com/zh-cn/library/ms189461(v=sql.105).aspx https://social.msdn.microsoft.c ...

  3. string 字符串的分隔处理与list的相互转换

    在指定 String 数组的每个元素之间串联指定的分隔符 String,从而产生单个串联的字符串.(来源于MSDN) 有两个重载函数:[C#]public static string Join(   ...

  4. python escape sequences

    转义字符 描述 \(在行尾时) 续行符 \\ 反斜杠符号 \' 单引号 \" 双引号 \a 响铃 \b 退格(Backspace) \e 转义 \000 空 \n 换行 \v 纵向制表符 \ ...

  5. fastjson生成和解析json数据

    本文讲解2点: 1. fastjson生成和解析json数据 (举例:4种常用类型:JavaBean,List<JavaBean>,List<String>,List<M ...

  6. react-redux知识点

    1.定义组件: 2.定义action: 3.定义Reducer:reducer1(state,action): 4.定义store:store(reducer1): 5.定义mapStateToPro ...

  7. 阅读layim代码小记,实现可以更改用户签名的方法

    用layim原版的时候发现,用户的签名是不能直接修改的,如下: 其实要改也很简单,查看一下源代码,然后加一个input进去,可是,加完之后是这样的: 没关系,给它一个样式,让它乖乖的“隐藏“起来. / ...

  8. Nginx Google 扩展

    安装配置详见: https://github.com/cuber/ngx_http_google_filter_module/blob/master/README.zh-CN.md tenginx详见 ...

  9. 大象数据库SQL存储过程(函数)

    -- Function: antifraudjudge(character varying) -- DROP FUNCTION antifraudjudge(character varying); C ...

  10. xshell 5连接linux服务器的技巧

    1.用sttp 方式连接服务器,命令识别不了,用ssh方式才能有效