Created
June 27, 2017 09:15
-
-
Save mrchrisadams/d31b73dbb92b887dae59291dc3e6057e to your computer and use it in GitHub Desktop.
Is there a nice way to do this in python?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class NormalClass(self, initialisation_arg): | |
pass | |
class HelpfulErrorMessageClass(self, initialisation_arg=None): | |
if self.initialisation_arg is None: | |
raise TypeError("some helpful error message explaining what initialisation_arg should be") | |
make1 = NormalClass() | |
# | |
# TypeError: __init__() missing 1 required positional argument: 'initialisation_arg' | |
make2 = HelpfulErrorMessageClass() | |
# "some helpful error message explaining what initialisation_arg should be" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment