| 1 |
import rich.repr |
| 2 |
|
| 3 |
|
| 4 |
@rich.repr.auto |
| 5 |
class Bird: |
| 6 |
def __init__(self, name, eats=None, fly=True, extinct=False): |
| 7 |
self.name = name |
| 8 |
self.eats = list(eats) if eats else [] |
| 9 |
self.fly = fly |
| 10 |
self.extinct = extinct |
| 11 |
|
| 12 |
|
| 13 |
# Note that the repr is still generated without Rich |
| 14 |
# Try commenting out the following line |
| 15 |
|
| 16 |
from rich import print |
| 17 |
|
| 18 |
BIRDS = { |
| 19 |
"gull": Bird("gull", eats=["fish", "chips", "ice cream", "sausage rolls"]), |
| 20 |
"penguin": Bird("penguin", eats=["fish"], fly=False), |
| 21 |
"dodo": Bird("dodo", eats=["fruit"], fly=False, extinct=True), |
| 22 |
} |
| 23 |
print(BIRDS) |