Rock It 《ML》JupyterLab 【丁】Code《六》前

學過數學的人是否知道四則運算 a \times b 有兩種『解釋』的呢?可以說 ab 個?還是說 ab 耶?然而不論 a=0b=0a \times b 都是『零』 0 也。所以任何數除以『零』 ,都是『錯誤』也!即使 0/0 在微積分『極限』 limits 觀點下,也只能說成『未定式』哩!

因此派生二

rock64@rock64:~python Python 2.7.13 (default, Sep 26 2018, 18:42:22)  [GCC 6.3.0 20170516] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> 1/0 Traceback (most recent call last):   File "<stdin>", line 1, in <module> ZeroDivisionError: integer division or modulo by zero </pre>    <span style="color: #666699;">以及派生三</span> <pre class="lang:default decode:true ">rock64@rock64:~ python3
Python 3.5.3 (default, Sep 27 2018, 17:25:39) 
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 1/0
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ZeroDivisionError: division by zero

 

皆產生『執行時』『錯誤』,不至認為『意義』有誤乎?!

然則為何『整數』除以『整數』卻引發『語言』變革呦!?

rock64@rock64:~python Python 2.7.13 (default, Sep 26 2018, 18:42:22)  [GCC 6.3.0 20170516] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> 1/3 0 >>> 1.0/3 0.3333333333333333 </pre>   <pre class="lang:default decode:true ">rock64@rock64:~ python3
Python 3.5.3 (default, Sep 27 2018, 17:25:39) 
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 1/3
0.3333333333333333

 

蓋因『禪味』不喜不『直覺』,又必須『小心』顧慮吧!!

所以面對『語意黑箱』時,終究不得不『除錯』ㄛ??

%debug

%debug [--breakpoint FILE:LINE] [statement [statement ...]]

Activate the interactive debugger.

This magic command support two ways of activating debugger. One is to activate debugger before executing code. This way, you can set a break point, to step through the code from the point. You can use this mode by giving statements to execute and optionally a breakpoint.

The other one is to activate debugger in post-mortem mode. You can activate this mode simply running %debug without any argument. If an exception has just occurred, this lets you inspect its stack frames interactively. Note that this will always work only on the last traceback that occurred, so you must call this quickly after an exception that you wish to inspect has fired, because if another one occurs, it clobbers the previous one.

If you want IPython to automatically do this on every exception, see the %pdb magic for more details.

Changed in version 7.3: When running code, user variables are no longer expanded, the magic line is always left unmodified.

positional arguments:
statement Code to run in debugger. You can omit this in cell
magic mode.
optional arguments:
--breakpoint <FILE:LINE>, -b <FILE:LINE>
Set break point at LINE in FILE.