Skip to content

Instantly share code, notes, and snippets.

@copyrighthero
Last active February 15, 2017 19:55
Show Gist options
  • Save copyrighthero/d8963461f22ef5064fb9003dbf818cf0 to your computer and use it in GitHub Desktop.
Save copyrighthero/d8963461f22ef5064fb9003dbf818cf0 to your computer and use it in GitHub Desktop.
# Exceptions
# Throw some errors with one line of lambda
# using the generator objects' throw method
_ERROR = lambda _ = "": (_ for _ in ()).throw(AssertionError("Some Error Occured" + _.__str__()))
_ERROR = lambda _ = "": (lambda:(yield _))().throw(AssertionError("Some Error Occured" + _.__str__()))
# So that you can do this
a = b if c else _ERROR()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment