python-cookbook icon indicating copy to clipboard operation
python-cookbook copied to clipboard

issue of example1.py of chapter 8

Open zangetsudo opened this issue 8 years ago • 1 comments

hi, David

i have just tested python-cookbook/src/8/lazily_computed_attributes/example1.py but happened to findout it does not workout like what the book tell, which i meam python cookbook, 3rd. After a little research, i found that you need to put a object there, like this : class lazyproperty(object): but i dont konw why. please tell me if you know.

PS:

TEST based on

PyCharm 2016.3.1 Build #PY-163.9735.8, built on December 15, 2016 Subscription is active until February 25, 2017 JRE: 1.8.0_111-b14 amd64 JVM: Java HotSpot(TM) 64-Bit Server VM by Oracle Corporation

Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 20:40:30) [MSC v.1500 64 bit (AMD64)] on win32

zangetsudo avatar Jan 12 '17 03:01 zangetsudo

The cookbook is written for Python 3. If using Python 2, you'll need to use new-style classes (i.e., inherit from object as you've noted).

dabeaz avatar Jan 12 '17 11:01 dabeaz