-
Notifications
You must be signed in to change notification settings - Fork 1
Update demo_code.py #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,9 @@ class BaseNumberGenerator: | |
| def __init__(self): | ||
| self.limits = (1, 10) | ||
|
|
||
| def get_float(self, f): | ||
| raise NotImplemented | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The code raises To indicate that an interface method must be implemented by subclasses, |
||
|
|
||
| def get_number(self, min_max): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| raise NotImplemented | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
raise NotImplementedcausesTypeErrorat runtimeThe code raises
NotImplemented, which is a special singleton value, not an exception. This will cause aTypeErrorto be raised at runtime, which can be misleading and obscure the developer's intent.Replace
NotImplementedwithNotImplementedError()to correctly signal that a method is abstract.