New Show Hacker News story: Show HN: Use Python docstrings as exception messages

Show HN: Use Python docstrings as exception messages
5 by yeti-sh | 0 comments on Hacker News.
The following exception @dataclass class PodBayDoorsStillClosed(DocumentedError): """ I’m sorry, {self.user_name}. I’m afraid I can’t do that. """ user_name: str when raised as raise PodBayDoorsStillClosed('Dave') will print PodBayDoorsStillClosed: I’m sorry, Dave. I’m afraid I can’t do that. Reduce the boilerplate, use more exception classes to better express the business logic, or invent your own use cases :) Can be tried out as: pip install documented which works for Python ⩾ 3.8.1.

Comments

Popular posts from this blog

New Show Hacker News story: Show HN: Natural language Twitter search using Codex

Internet Download Manager Universal Crack is Here ! [IDM 6.25 Build 10 UPDATED]

New Show Hacker News story: Show HN: Movis – A Video Editing Library in Python