python3-cookbook
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的更多相关文章
- Python 学习教程
<Core Python Programming>勘误参考表 http://starship.python.net/crew/wesc/cpp/errata2.htm 笨办法学 Pytho ...
- 如何系统地自学 Python?
最近开始系统的学习Python,以及整理的一些资料.github记录着个人自学 Python 的过程,持续更新.欢迎大家一起来完善这个自学Python学习的项目,给后来者一个参考的学习过程.githu ...
- python学习路线--从入门到入土
入门技术博客 进阶自己挑选 入门基础 Python入门相对容易又可以干很多事(网站,运维,数据,爬虫等),是一门方便的工具语言.2016年TIOBE排名显示Python已经名列第四,成为脚本语言之首. ...
- 自学 Python
如何系统地自学 Python? 最近开始系统的学习Python,以及整理的一些资料.github记录着个人自学 Python 的过程,持续更新.欢迎大家一起来完善这个自学Python学习的项目,给 ...
- 最全数据分析资料汇总(含python、爬虫、数据库、大数据、tableau、统计学等)
一.Python基础 Python简明教程(Python3) Python3.7.4官方中文文档 Python标准库中文版 廖雪峰 Python 3 中文教程 Python 3.3 官方教程中文版 P ...
- 计算机电子书 2016 BiliDrive 备份
下载方式 根据你的操作系统下载不同的 BiliDrive 二进制. 执行: bilidrive download <link> 链接 文档 链接 Go入门指南.epub (1.87 MB) ...
- 我与python3擦肩而过(二)—— csv文件头哪去啦?
在看Python Data Visualization Cookbook 这本书(基于python2),开始时读取csv文件头的时候出现问题.查了资料,又是python3的问题,从这个链接找到答案. ...
- 学python3的书
<Python Cookbook>3rd Edition http://python3-cookbook.readthedocs.io/zh_CN/latest/copyright.htm ...
- python2和python3的区别——持续更新
1.在 cookbook 上看到的,python3支持 *运算符 来接收迭代变量,如: a, *b = [, , , ] python2是不支持的! 2.在 cookbook 上看到的,python3 ...
- Python3 系列之 并行编程
进程和线程 进程是程序运行的实例.一个进程里面可以包含多个线程,因此同一进程下的多个线程之间可以共享线程内的所有资源,它是操作系统动态运行的基本单元:每一个线程是进程下的一个实例,可以动态调度和独立运 ...
随机推荐
- Android实现拖动进度条改变图片透明度
layout文件: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:an ...
- Metasploit连接postgres数据库
操作环境为Kali虚拟机 root@kali:~# apt-get install postgresql 启动服务 root@kali:~# service postgresql start [ ok ...
- 关于setInterval()里的this和细节
setInterval(fn,t);里的fn中,要使用外部类的this,则需要先将this保存起来,再使用保存的this,不能直接使用this,里面的this是指向window对象,记住setInte ...
- 【P1373】奶牛的卧室
看山神的题解写出来的,sro_dydxh_orz 原题:奶牛们有一个习惯,那就是根据自己的编号选择床号.如果一头奶牛编号是a,并且有0..k-1一共k张床,那么她就会选择a mod k号床作为她睡 ...
- win7win8一键取得超级管理员权限
win7win8有时会出现删除不了文件的情况,弹窗提示需要某某权限,下面为解决办法: 在普通帐户中快速获得最高的权限: 新建一个.txt文本,将下面的代码复制粘贴到文件中,另存为或重命名为.reg文件 ...
- 黑马程序员——JAVA基础之基本数据类型包装类和1.5JDK新特性装箱
------- android培训.java培训.期待与您交流! ---------- 基本数据类型包装类: byte Byte short Short int Integer char Charac ...
- (转) An overview of gradient descent optimization algorithms
An overview of gradient descent optimization algorithms Table of contents: Gradient descent variants ...
- ps色阶
三原色
- A better SHOW TABLE STATUS
From command line we have the entire MySQL server on hands (if we have privileges too of course) but ...
- XMLHttpRequest 对象
XMLHttpRequest 对象 XML XSLTXML 解析器XMLHttpRequest 对象用于在后台与服务器交换数据. 什么是 XMLHttpRequest 对象? XMLHttpReque ...