dynamic attributes, descriptors and first concurrency examples

This commit is contained in:
Luciano Ramalho
2015-01-17 22:40:40 -02:00
parent 0618105a47
commit dd1a53ff71
27 changed files with 1151 additions and 216 deletions

View File

@@ -0,0 +1,29 @@
"""
Alex Martelli, _Python in a Nutshell, 2e._ (O'Reilly, 2006), p. 101
==========================
Properties and inheritance
==========================
Properties are inherited normally, just like any other attribute.
However, theres a little trap for the unwary: the methods called
upon to access a property are those that are defined in the class
in which the property itself is defined, without intrinsic use of
further overriding that may happen in subclasses. For example:
"""
class B(object):
def f(self):
return 23
g = property(f)
class C(B):
def f(self):
return 42
c = C()
print(c.g) # prints 23, not 42