Show HN: Use Python docstrings as exception messages https://ift.tt/GwH3r6B

Show HN: Use Python docstrings as exception messages 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. https://ift.tt/0rI1B74 October 7, 2023 at 01:09AM

Komentar

Postingan populer dari blog ini

Twin Peaks for All: Survey Results

Launch HN: Riot (YC W20) – Phishing training for your team https://ift.tt/2QIueZL

Show HN: Guish – A GUI for constructing and executing Unix pipelines https://ift.tt/HrXz5ub