Skip to content

Instantly share code, notes, and snippets.

@mrchrisadams
Created June 27, 2017 09:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrchrisadams/d31b73dbb92b887dae59291dc3e6057e to your computer and use it in GitHub Desktop.
Save mrchrisadams/d31b73dbb92b887dae59291dc3e6057e to your computer and use it in GitHub Desktop.
Is there a nice way to do this in python?
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