故意侮辱例外
insult-error的Python项目详细描述
这个包提供了一组侮辱性异常,您可以使用它们 你未来的自我嘲笑,打扰你的合作者,或者两者兼而有之。
核心特性是InsultErrorexception类,它的行为 就像一个普通的例外有一些不同:1。引发的错误 是一个随机选择的子类,有一个愚蠢的,侮辱性的名字2。如果没有 如果提供消息,则错误将使用随机侮辱消息3。一个 特殊关键字参数rating提供了一些控制如何 冒犯你希望错误和信息是(1是最温和的,10 卑鄙)
请贡献!如果不局限于 一组微不足道的初始选项。显然,种族主义者、性别歧视者或其他人 胡说八道的笑话是不受欢迎的。
示例用法
frominsult_errorimportInsultError# raise a random insult with a random message (defaults to rating=5)raiseInsultError# >>> NotThisAgain: Don't believe everything you think.# raise a random insult with a user-specified messageraiseInsultError('This is my message')# >>> NotThisAgain: This is my message# raise a random insult with <= 2 ratingraiseInsultError(rating=2)# >>> ForGodsSake: I don’t have the time or the crayons to explain this to you.# raise a random insult with <= 6 ratingraiseInsultError(rating=6)# >>> FuckYouBuddy: I envy people who have never met you.# handle InsultError exceptions (just like normal, non-insulting errors)try:raiseInsultErrorexceptInsultErrorprint('Better luck next time!')# >>> Better luck next time!