mirror of
https://github.com/apachecn/ailearning.git
synced 2026-04-24 10:34:08 +08:00
2020-10-19 21:08:55
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
In [1]:
|
||||
|
||||
```
|
||||
```py
|
||||
class Leaf(object):
|
||||
def __init__(self, color='green'):
|
||||
self.color = color
|
||||
@@ -26,7 +26,7 @@ class MapleLeaf(ColorChangingLeaf, DeciduousLeaf):
|
||||
|
||||
In [2]:
|
||||
|
||||
```
|
||||
```py
|
||||
leaf = MapleLeaf()
|
||||
|
||||
leaf.change("yellow")
|
||||
@@ -36,7 +36,7 @@ leaf.fall()
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
```py
|
||||
yellow
|
||||
Plunk!
|
||||
|
||||
@@ -46,7 +46,7 @@ Plunk!
|
||||
|
||||
In [3]:
|
||||
|
||||
```
|
||||
```py
|
||||
class Leaf(object):
|
||||
def __init__(self, color='green'):
|
||||
self.color = color
|
||||
@@ -68,20 +68,20 @@ class MapleLeaf(ColorChangingLeaf, DeciduousLeaf):
|
||||
|
||||
In [4]:
|
||||
|
||||
```
|
||||
```py
|
||||
leaf = MapleLeaf()
|
||||
leaf.fall()
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
```py
|
||||
Spalt!
|
||||
|
||||
```
|
||||
|
||||
In [5]:
|
||||
|
||||
```
|
||||
```py
|
||||
class MapleLeaf(DeciduousLeaf, ColorChangingLeaf):
|
||||
pass
|
||||
|
||||
@@ -89,13 +89,13 @@ class MapleLeaf(DeciduousLeaf, ColorChangingLeaf):
|
||||
|
||||
In [6]:
|
||||
|
||||
```
|
||||
```py
|
||||
leaf = MapleLeaf()
|
||||
leaf.fall()
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
```py
|
||||
Plunk!
|
||||
|
||||
```
|
||||
@@ -104,14 +104,14 @@ Plunk!
|
||||
|
||||
In [7]:
|
||||
|
||||
```
|
||||
```py
|
||||
MapleLeaf.__mro__
|
||||
|
||||
```
|
||||
|
||||
Out[7]:
|
||||
|
||||
```
|
||||
```py
|
||||
(__main__.MapleLeaf,
|
||||
__main__.DeciduousLeaf,
|
||||
__main__.ColorChangingLeaf,
|
||||
@@ -121,14 +121,14 @@ Out[7]:
|
||||
|
||||
In [8]:
|
||||
|
||||
```
|
||||
```py
|
||||
MapleLeaf.mro()
|
||||
|
||||
```
|
||||
|
||||
Out[8]:
|
||||
|
||||
```
|
||||
```py
|
||||
[__main__.MapleLeaf,
|
||||
__main__.DeciduousLeaf,
|
||||
__main__.ColorChangingLeaf,
|
||||
@@ -140,7 +140,7 @@ Out[8]:
|
||||
|
||||
In [9]:
|
||||
|
||||
```
|
||||
```py
|
||||
class A(object):
|
||||
pass
|
||||
|
||||
@@ -165,13 +165,13 @@ class D(B1, C):
|
||||
|
||||
In [10]:
|
||||
|
||||
```
|
||||
```py
|
||||
D.mro()
|
||||
|
||||
```
|
||||
|
||||
Out[10]:
|
||||
|
||||
```
|
||||
```py
|
||||
[__main__.D, __main__.B1, __main__.B, __main__.C, __main__.A, object]
|
||||
```
|
||||
Reference in New Issue
Block a user