【教程 】【iPython 】 Learning IPython for Interactive Computing and Data Visualizatio

file:///D:/搜狗高速下載/【教程】【Python】/【教程 】【iPython 】 Learning IPython for Interactive Computing and Data Visualizatio.PDF

Example – executing C++ code in IPython 113頁 2015/8/15 14:03:55

? ? it might be? a better idea to use Cython or SciPy.weave。The extension defines a new cell magic named cpp. The idea is that one will be able? to write C++ code directly in the cell, and it will be automatically compiled and? executed. The cell output will contain the standard output of the code. Here is an? explanation of how this extension works:該擴展定義了一個名為CPP的新細胞的魔法。我們的想法是,一個將能直接在單元寫C ++代碼,并且它將自動編譯和執(zhí)行。所述單元輸出將包含代碼的標(biāo)準(zhǔn)輸出。下面是如何擴建工程的解釋:

? ? We create a new class derived from IPython.core.magic.Magics我們創(chuàng)建一個從IPython.core.magic.Magics派生新類

? ? In this class, we create a new method with a cell_magic decorator: it will? implement the cpp cell magic在這個類中,我們創(chuàng)建了一個新的方法與cell_magic裝飾:將實施的CPP細胞魔法

? ? This method accepts the cell's code as input, writes this C++ code in a? temporary file, and calls the g++ compiler to create an executable這個方法接受小區(qū)的代碼作為輸入,在臨時文件中寫入這個C ++代碼,并調(diào)用g ++編譯器創(chuàng)建可執(zhí)行

Improving this example 115頁 2015/8/15 14:36:28

? ? More generally, the same techniques can be used to run? non-Python code in IPython. It may even be possible to share? variables between Python and the other languages. 更一般地,相同的技術(shù)可以被用來在IPython的運行非Python代碼。它甚至有可能共享Python和其它語言之間的變量。

? ? The IPython extensions are particularly powerful in the context of the notebook,? because they notably allow the implementation of arbitrarily complex behaviors to? the cells' code. IPython的擴展是在筆記本中尤其強大,因為他們特別允許任意復(fù)雜行為的實施,細胞的代碼。

Rich representations in the frontend

? ? one just needs to implement a method called _repr_*_ with *? being svg, png, jpeg, html, json, pretty, or latex. For instance, let's define a class,? Disc, with a SVG representation method

Embedding IPython 117頁

? ? 在各種需要暫停的交互場合

? ? The easiest way to integrate IPython in a program is to call IPython.embed() at any? point in your Python program (after import IPython). You can also specify custom? options, including the input/output templates in the command-line interface, the? startup/exit messages, and so on。You can find more information at http://ipython.? org/ipython-doc/stable/interactive/reference.html#embedding-ipython.

Final words? ?

? ? The possibility to create? custom interactive widgets in the notebook is planned and is likely to be a major? feature of the whole project. More information about the upcoming developments can? be found at https://github.com/ipython/ipython/wiki/Roadmap:-IPython and? http://ipython.org/_static/sloangrant/sloan-grant.html.

? GitHub project page: https://github.com/ipython/ipython

? Wiki: https://github.com/ipython/ipython/wiki

? User mailing list: http://mail.scipy.org/mailman/listinfo/ipython-user

? Chat room: https://www.hipchat.com/ghSp7E1uY?

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 昨天分享了三個關(guān)于高效的習(xí)慣,今天看到了晨讀后,關(guān)于另外四個好習(xí)慣:雙贏思維,知彼解己,統(tǒng)合綜效和不斷更新。想通過...
    九悠閱讀 389評論 2 8
  • 終于定下了返程機票,生活開始看到曙光。
    阿三小卷卷閱讀 169評論 0 0

友情鏈接更多精彩內(nèi)容