02 2020 档案
摘要:Operator overloading allows user-defined objects to interoperate with infix operators such as + and | or unary operators like - and ~ . More generally
阅读全文
摘要:1. Subclassing Built-In Types Is Tricky Since Python 2.2, subclassing built-in types such as list or dict can be done but there is a major caveat: the
阅读全文
摘要:An abstract class represents an interface. Interfaces are the subject of this chapter: from the dynamic protocols that are the hallmark of ducking typ
阅读全文
摘要:1. Vector Take #1: Vector2d Compatible The best practice for a sequence constructor is to take the data as an iterable argument in the constructor, li
阅读全文
摘要:1. Object Representations Every object-oriented language has at least one standard way of getting a string representation from any object. Python has
阅读全文
摘要:1. Varaibles Are Labels, Not Boxes. Python varaibles are like reference variables in Java, so it's better to think of them as labels attached to objec
阅读全文
摘要:Function decorators let us "mark" functions in the source code to enhance their behavior in some way. This is powful stuff, but mastering it requires
阅读全文
摘要:Although design patterns are language-independent, that does not mean every pattern applies to every language. If we assumed procedural languages, we
阅读全文