用于处理和引发异常的python实用程序

ctodd-python-lib-exceptions的Python项目详细描述


克里斯托弗·托德的项目字符串名称

项目名称项目负责…

图书馆…

目录

依赖关系

python包

  • 不适用

create_exceptions.py

异常帮助程序。此文件显示了python中的异常类型和用于生成特定异常的函数调用。这对于单元测试、调试和其他可能需要有意中断部分代码的任务非常有用。

功能:

def create_and_throw_exception(exception_name=None):
    """
        Purpose:
            Create and Throw an exception from the exception
            types in the file. if exception_name is passed in,
            throw that specific exception if it has been
            coded in the library
        Args:
            exception_name (String ExceptionType): Type of exception
                to throw
        Returns:
            N/A: should never return, should always raise
    """
def create_zero_division_exception():
    """
        Purpose:
            Throw ZeroDivisionError Exception
        Args:
            N/A
        Returns:
            N/A
    """
def create_overflow_exception():
    """
        Purpose:
            Throw OverflowError Exception
        Args:
            N/A
        Returns:
            N/A
    """
def create_type_exception():
    """
        Purpose:
            Throw TypeError Exception
        Args:
            N/A
        Returns:
            N/A
    """
def create_assertion_exception():
    """
        Purpose:
            Throw AssertionError Exception
        Args:
            N/A
        Returns:
            N/A
    """
def create_attribute_exception():
    """
        Purpose:
            Throw AttributeError Exception
        Args:
            N/A
        Returns:
            N/A
    """
def create_name_exception():
    """
        Purpose:
            Throw NameError Exception
        Args:
            N/A
        Returns:
            N/A
    """
def create_index_exception():
    """
        Purpose:
            Throw IndexError Exception
        Args:
            N/A
        Returns:
            N/A
    """
def create_key_exception():
    """
        Purpose:
            Throw KeyError Exception
        Args:
            N/A
        Returns:
            N/A
    """
def create_unbound_local_exception():
    """
        Purpose:
            Throw UnboundLocalError Exception
        Args:
            N/A
        Returns:
            N/A
    """

unsupported_exception.py

不支持异常类。当前不执行任何操作,但允许在create_exceptions中指定失败的调用

课程:

class UnsupportedException(Exception):
    """
    Purpose:
        An Unsupported Exception is raised when the lib is asked to try
        and raise an exception that has yet to be programmed. this way,
        som exception is raised, but it can be handled in a way that
        knows the specified exception isn't raised
    """

脚本示例

用于测试和与库交互的示例可执行python脚本/模块。这些示例显示了库的用例,可以用作与库一起开发的模板,也可以用作一次性开发工作。

不适用

注释

  • 依赖于f-string符号,它仅限于python3.6。通过重构删除这些内容,可以使用python3.0.x到3.5.x进行开发

待办事项

  • UnitTest框架已就位,但缺少测试

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java ProcessBuilder在使用多个参数时运行不正常   java如何使用Spring数据ORM/JPA创建EntityManagerFactory?   将Velocity宏转换为Java指令   internet上的Java TCP/IP服务器客户端通信   java为什么JDK 8允许一个局部内部类(在方法内部)访问封闭方法的非最终局部变量?   基于Java的比率算法   java应用程序在选择列表首选项时出错   java保存对象以供以后使用   java如何使用MySQL JDBC驱动程序连接Android和MySQL   java Zipkin可以用于控制台应用程序   java单击刷新Servlet页面显示重复内容   java如何递归地反转字符串数组?   java如何使用inputStream作为outputStream的文本?   java扩展令牌选择操作符   java在映射中使用通用枚举类   arraylist如何使用JAVA流从对象列表中查找平均值   windows将FileInputStream和FileOutputStream传递给ffmpeg进行转码(使用JAVEJava音频视频编码)   java Ant脚本在执行CVS签出后找不到目标   重复值情况下的java插入排序,双链表ADT   java如何在Accumulo中获取数据库查询计数