You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: abstract_factory/README.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -60,7 +60,7 @@ Your Python code may produce errors. It happens to everybody. It is hard to fore
60
60
61
61
Use the `Try`, `Except` and optional `finally` keywords to manage error handling.
62
62
63
-
In the example code, if no chair or table is returned, an `Exception` error is raised and it includes a text string that can be read and written to the console.
63
+
In the example code, if no chair or table is returned, an `Exception` error is raised, and it includes a text string that can be read and written to the console.
64
64
65
65
Within your code you can use the `raise` keyword to trigger Python built in exceptions or even create your own.
66
66
@@ -69,9 +69,9 @@ def get_furniture(furniture):
69
69
"Static get_factory method"
70
70
try:
71
71
if furniture in ['SmallChair', 'MediumChair', 'BigChair']:
72
-
return ChairFactory().get_chair(furniture)
72
+
return ChairFactory.get_chair(furniture)
73
73
if furniture in ['SmallTable', 'MediumTable', 'BigTable']:
74
-
return TableFactory().get_table(furniture)
74
+
return TableFactory.get_table(furniture)
75
75
raiseException('No Factory Found')
76
76
exceptExceptionas _e:
77
77
print(_e)
@@ -97,7 +97,7 @@ The `try/except` allows the program to continue running, as can be verified by t
97
97
98
98
Alternatively, if your code didn't include the `try/except` and optional `finally` statements, the Python interpreter would return the error `NameError: name 'my_var' is not defined` and the program will crash at that line.
99
99
100
-
Also note how the default Python inbuilt error starts with `NameError`. You can handle this specific error explicitly using an extra `except` keyword.
100
+
Also note how the default Python inbuilt error starts with `NameError`. You can handle this specific error explicitly using an extra `except` keyword.
0 commit comments