Expert Python programming - Reading Notes

1. MRO: method resolution order

lookup order:

L(MyClass) = [MyClass, merged(L(Base1), L(Base2), Base1, Base2)]

2. super(...)

必须所有的父类都call super, 不然会有不可预测的问题

3. class variable & instance variable

查找顺序

 都可以通过 self.x 访问, 所以instance variable 会覆盖class variable, 而class variable 可以用来定义一个default value for instance variable.

如果是mutable的,会有些特殊

4. descriptor

 只能定义在class level, 可以通过在instance里记录每次设置的value来为每个instance 定义不同的value for class variable

时间: 2024-08-25 14:09:40

Expert Python programming - Reading Notes的相关文章

《Expert Python Programming》pdf

下载地址:网盘下载 内容简介  · · · · · · Python is a dynamic programming language, used in a wide range of domains by programmers who find it simple, yet powerful. From the earliest version 15 years ago to the current one, it has constantly evolved with productiv

TTD in Expert Python Programming

Test-Driven Development PrinciplesTDD consists of writing test cases that cover a desired feature, then writing the feature itself. In other words, the usage examples are written before the code even exists.For example, a developer who is asked to wr

C专家编程 Expert C Programming

该书中一些思想还是比较有用的,但随着编译器以及规范的变化,书中有些内容已经发生了变化,以下是实践之后的一些总结. 1 - typedef int x[10] 和 define x int[10]  区别 define 定义为变量替换,而typedef为声明替换; #define peach int; unsigned peach i;  //wrong typedef int banana; unsigned banana i; //wrong 声明替换用typedef 识别数组和函数指针 e.

Master the 10 Most Common Python Programming Problems - 10大最常见的Python编程错误

http://blog.csdn.net/pipisorry/article/details/45175457 Introduction 本文介绍python编程中很难捕捉10大错误 (Note: This article is intended for a more advanced audience than Common Mistakes of Python Programmers, which is geared(适合) more toward those who are newer t

Tomcat Reading Notes

HTTP the client who initiates a transcation by establishing a connection and seding an HTTP request. the web server is in no position to contact a clinet or make a callback connection to the client. either client or the server can terminate a connect

reading notes -- A Report from the Trenches

Building, Maintaining, and Using Knowledge Bases: A Report from the Trenches ABSTRACT 一个知识库(KB) 是一个集合,包含有概念,实例和关系. 论文中描述了一个工业级使用的知识库,从建立维护到使用的全过程.尤其是建立,更新和组织一个大型的知识库,以及其大量的应用. 一.INTRODUCTION 知识库及知识图谱的应用大概有:DBLP, Google Scholar, Internet Movie Databas

C语言学习书籍推荐《C专家编程Expert C Programming Deep C Secrets》下载

Peter Van Der Linden (作者) <C和C++经典著作 C专家编程Expert C Programming Deep C Secrets>展示了C程序员所使用的编码技巧,并专门开辟了一章对C++的基础知识进行了介绍.书中C的历史.语言特性.声明.数组.指针.链接.运行时.内存以及如何进一步学习C++等问题进行了细致的讲解和深入的分析.全书撷取几十个实例进行讲解,对C程序员具有非常高的实用价值.<C和C++经典著作?C专家编程Expert C Programming De

第一次碰到try-except(core python programming 2nd Edition 3.6)

1 # coding: utf-8 # 使用Windows系统,首行'#!/usr/bin/env Pyton'无用,全部改为'# coding: utf-8' 2 3 'readtextfile.py -- read and display text file' 4 5 # get filename 6 fname = raw_input('Enter filename: ') 7 print 8 9 # attempt to open file for reading 10 try: 11

Beginning Python Chapter 3 Notes

变量(variable)是储存数据的实体,在Python中也被称为"名称"(name). 1.Python"名称"基本命名法则 1.1) "名称"不能是Python的内置词(保留字.关键字). 1.2) "名称"由数字.下划线.字母组成. Python关键字表以及其余约定俗称的规则将在另一篇文章中详细阐述. 原文的排版也是醉了,讲名称时又讲起了内置数据类型.为了尊重原文,所以下面还是谈谈Python的另外几种基本数据类型:元组