Skip to content

Commit bff01ce

Browse files
committed
files-post-TR1
1 parent bbea532 commit bff01ce

19 files changed

+99
-124
lines changed

python-isinstance/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ This folder provides the code examples for the Real Python tutorial [How Does `i
44

55
The `.py` files contain the code found in the tutorial.
66

7-
When setting up your tutorial environment, make sure `balls.py`, `balls_v2.py` and `customiterables.py` are in your program folder. You'll need to import content from these during the tutorial.
7+
When setting up your tutorial environment, make sure `balls.py`, `balls_v2.py`, and `player_iterables.py` are in your program folder. You'll need to import content from these to replicate the tutorial examples.
88

99

python-isinstance/balls.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,15 @@
1-
from abc import ABC, abstractmethod
2-
3-
4-
class Ball(ABC):
1+
class Ball:
52
def __init__(self, color, shape):
63
self.color = color
74
self.shape = shape
85

9-
@abstractmethod
10-
def get_shape(self):
11-
pass
12-
136

147
class PoolBall(Ball):
158
def __init__(self, color, number):
169
super().__init__(color, shape="sphere")
1710
self.number = number
1811

19-
def get_shape(self):
20-
return self.shape
2112

22-
23-
class AmericanFootBall(Ball):
13+
class FootBall(Ball):
2414
def __init__(self, color):
2515
super().__init__(color, shape="elongated ellipsoid")
26-
27-
def get_shape(self):
28-
return "Elongated Ellipsoid"

python-isinstance/basic_iterable.py

Lines changed: 0 additions & 8 deletions
This file was deleted.

python-isinstance/bool_int_test.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,5 @@
1414
for element in test_data:
1515
"bool" if isinstance(element, bool) else "int"
1616

17-
# Try and avoid this.
18-
# for element in test_data:
19-
# "bool" if type(element) is bool else "int"
17+
for element in test_data:
18+
"bool" if type(element) is bool else "int"
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,5 @@ def calculate_area(length, breadth):
55

66

77
calculate_area(5, 3)
8-
98
calculate_area(5, "3")
10-
119
calculate_area("5", "3")

python-isinstance/consolidation1_solution.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
from balls import Ball, FootBall, PoolBall
2-
3-
football = FootBall("brown")
4-
ball = Ball("green", "sphere")
5-
6-
71
isinstance(football, FootBall)
82

93
isinstance(football, PoolBall)

python-isinstance/consolidation2_solution.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,17 @@
66
eight_ball = PoolBall("black", 8)
77
football = AmericanFootBall("brown")
88

9-
isinstance(eight_ball, ABC)
9+
# Question 1
1010

11+
isinstance(eight_ball, ABC)
1112
isinstance(football, ABC)
1213

14+
# Question 2
15+
1316
isinstance(isinstance, Callable)
1417

18+
# Question 3
19+
1520
isinstance(eight_ball.get_shape, Callable)
1621

1722
isinstance(PoolBall, Callable)

python-isinstance/customiterable_one_tests.py

Lines changed: 0 additions & 9 deletions
This file was deleted.

python-isinstance/customiterable_three_tests.py

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)