2020-10-19 21:08:55

This commit is contained in:
wizardforcel
2020-10-19 21:08:55 +08:00
parent 7f63048035
commit ab0caba1f0
140 changed files with 3982 additions and 3982 deletions

View File

@@ -1,6 +1,6 @@
# super() 函数
```
```py
super(CurrentClassName, instance)
```
@@ -8,7 +8,7 @@ super(CurrentClassName, instance)
In [1]:
```
```py
class Leaf(object):
def __init__(self, color="green"):
self.color = color
@@ -29,7 +29,7 @@ class MapleLeaf(Leaf):
In [2]:
```
```py
mleaf = MapleLeaf()
print mleaf.color
@@ -38,7 +38,7 @@ print mleaf.color
```
```
```py
green
Splat!
red
@@ -49,7 +49,7 @@ red
In [3]:
```
```py
import numpy as np
class Forest(object):
@@ -106,7 +106,7 @@ class Forest(object):
In [4]:
```
```py
class BurnableForest(Forest):
"""
Burnable forest support fires
@@ -160,7 +160,7 @@ class BurnableForest(Forest):
In [5]:
```
```py
forest = Forest()
forest.grow_trees()
@@ -169,7 +169,7 @@ print forest.tree_fraction
```
```
```py
0.00284444444444
```
@@ -178,7 +178,7 @@ print forest.tree_fraction
In [6]:
```
```py
burnable_forest = BurnableForest()
```
@@ -187,7 +187,7 @@ burnable_forest = BurnableForest()
In [7]:
```
```py
burnable_forest.grow_trees()
burnable_forest.start_fires()
burnable_forest.burn_trees()
@@ -195,7 +195,7 @@ print burnable_forest.tree_fraction
```
```
```py
0.00235555555556
```
@@ -204,7 +204,7 @@ print burnable_forest.tree_fraction
In [8]:
```
```py
import matplotlib.pyplot as plt
%matplotlib inline
@@ -511,50 +511,50 @@ QloBSvaEENIKULInhJBWgJI9IYS0ApTsCSGkFaBkTwghrcD/B0LrH2UND7W5AAAAAElFTkSuQmCC
In [9]:
```
```py
forest
```
Out[9]:
```
```py
Forest(size=(150, 150))
```
In [10]:
```
```py
forest2
```
Out[10]:
```
```py
BurnableForest(size=(150, 150))
```
In [11]:
```
```py
print forest
```
```
```py
Forest
```
In [12]:
```
```py
print forest2
```
```
```py
BurnableForest
```