有什么用python语法提高A,L?

时间:2016-05-19 01:55:47

标签: python-2.7 exception raise

如果调用以下代码,其中L是列表,那么L是如何使用的?

raise A, L

1 个答案:

答案 0 :(得分:1)

请注意,此语法仅在Python 2中可用.Python 3具有lib2to3/fixes/fix_raise.py

在2到3的翻译系统中,它以下面的docstring开头,给你一个关于文档保持沉默的提示(AFAIK):

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<html>
  <body>
    <table id="my_table">
      <thead>
        <th>State</th>
        <th>Miles</th>
      </thead>
      <tbody>
        
      </tbody>
    </table>
    
    <script type="text/html" id="row_template">
      <tr>
        <td>{{state}}</td>
        <td>{{miles}}</td>
      </tr>
    </script>

  </body>
</html

归结为Fixer for 'raise E, V, T' raise -> raise raise E -> raise E raise E, V -> raise E(V) raise E, V, T -> raise E(V).with_traceback(T) raise E, None, T -> raise E.with_traceback(T) raise (((E, E'), E''), E'''), V -> raise E(V) raise "foo", V, T -> warns about string exceptions CAVEATS: 1) "raise E, V" will be incorrectly translated if V is an exception instance. The correct Python 3 idiom is raise E from V but since we can't detect instance-hood by syntax alone and since any client code would have to be changed as well, we don't automate this. 等同于raise FooException, [1, 2];但你应该总是使用后者。