日志处理程序和异常挂钩来描述消息。
say_it_to_my_face的Python项目详细描述
当面说
你有没有写过一堆代码,一切都很顺利 在计算机历史上第一次,然后一些可怕的异常杀死你的 希望和梦想?你当时有没有威胁性地瞥了一眼电脑, 你所有问题的根源,低声说“我打赌你不会说 当着我的面。”
现在可以了。
会的。
用法
让翻译告诉你你的缺点, “对我的脸说例外”功能可用。它使用日志 用于读取通过异常挂钩传入的异常消息的处理程序。
>>> import say_it_to_my_face >>> say_it_to_my_face.say_exceptions_to_my_face() >>> raise AttributeError("lol that's not an attribute") # A voice will read the message to you Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: lol that's not an attribute
您还可以通过该日志处理程序向您读取所有日志。 您也可以将要使用的声音的名称传递给它,尽管默认情况下 从你的现场获取。
>>> import logging >>> import say_it_to_my_face >>> handler = say_it_to_my_face.SayItToMyFace(voice="Daniel") >>> logger = logging.getLogger() >>> logger.addHandler(handler) >>> logger.critical("why did you do that?")
要求
- python>;=3.3
- os x上的say程序,或者ubuntu上的espeak程序, 虽然我没有试过,但看起来很相似。