zoukankan      html  css  js  c++  java
  • 契约式设计 契约式编程 Design by contract

    Design by contract - Wikipedia https://en.wikipedia.org/wiki/Design_by_contract

    What is the use of "assert" in Python? - Stack Overflow https://stackoverflow.com/questions/5142418/what-is-the-use-of-assert-in-python

    7. Simple statements — Python 3.6.6rc1 documentation https://docs.python.org/3/reference/simple_stmts.html#assert

    7.3. The assert statement

    Assert statements are a convenient way to insert debugging assertions into a program:

    assert_stmt ::=  "assert" expression ["," expression]
    

    The simple form, assert expression, is equivalent to

    if __debug__:
        if not expression: raise AssertionError
    

    The extended form, assert expression1, expression2, is equivalent to

    if __debug__:
        if not expression1: raise AssertionError(expression2)
    

    These equivalences assume that __debug__ and AssertionError refer to the built-in variables with those names. In the current implementation, the built-in variable __debug__ is True under normal circumstances, False when optimization is requested (command line option -O). The current code generator emits no code for an assert statement when optimization is requested at compile time. Note that it is unnecessary to include the source code for the expression that failed in the error message; it will be displayed as part of the stack trace.

    Assignments to __debug__ are illegal. The value for the built-in variable is determined when the interpreter starts.

    7.4.

  • 相关阅读:
    为php5.6.30安装redis扩展
    Laravel利用pusher推送消息
    php闭包使用例子
    利用反射给类中方法加钩子
    mysql删除重复记录
    DB门面,查询构建器,Eloquent ORM三者的CURD
    Laravel5.1之表单验证
    服务提供者及门面
    批量搜索并替换内容
    Laravel之Elixir
  • 原文地址:https://www.cnblogs.com/rsapaper/p/9228319.html
Copyright © 2011-2022 走看看