<TeXmacs|1.99.2><style|tmdoc><\body><tmdoc-title|Usage of the Python Plugin>Separate statements by using <key|shift return>. When you are ready to have<name|Python> evaluate your input press <key|return>. \ If you would likethis behaviour reversed select <menu|Focus|Input options|Multiline input>.The plugin has the following features:<paragraph|Autocompletion>Type the fist letters of a built-in command or acommand you have previously defined and then press <key|tab> until you finda completion of your choice.<paragraph|<name|PostScript> output and <python|matplotlib> support>Use thefunction <python|ps_out (data)> to output <name|PostScript> data directlyto <TeXmacs>:<\itemize><item>If the <verbatim|data> is a string and has more than one line, itwill be processed as raw <name|PostScript> data.<item>If <verbatim|data> is a simple string, it is assumed to contain thefilename of a <name|PostScript> file which will be read (if the file hasno extension, the defaults <verbatim|.eps> and <verbatim|.ps> will betried in that order).<item>If <verbatim|data> is an instance of<python|matplotlib.pyplot.Figure> and <strong|only if additionally> abackend supporting output to (encapsulated) <name|PostScript> is beingused, then the plugin will call <python|data.savefig()> to save the plotto a string and copy it into the <TeXmacs> document. See <hlink|theexamples section|python-demo.en.tm>.<item>If <verbatim|data> is a file or other object which provides a'<verbatim|read>' method, the <name|PostScript> data will be obtained bycalling such method.</itemize><paragraph|Help window>Type any name followed by a question mark <key|?> tohave a popup window with the associated <python|help()> as well as the codeif it is available through <python|inspect.getsource()>. For instance:<\session|python|default><\input>\<gtr\>\<gtr\>\<gtr\>\<|input>ps_out?</input></session><paragraph|Usage as a scripting language>Selecting the menu item<menu|Insert|Fold|Executable|Python> will produce the following output:<script-input|python|default||>. You may enter any <name|Python> expressionor statement in the yellow box, e.g <script-input|python|default|1+2|3>.Hitting <shortcut|(kbd-return)> inside the box will alternate between theunevaluated input and the evaluated output.For more complex code you can use <shortcut|(kbd-shift-return)> to enablemulti-line input. Note however that <em|expressions> (e.g. <python|1+2>),<python|>are evaluated using <python|eval()> and the resulting value issent to <TeXmacs>, whereas <em|statements> (e.g. <python|print "hi there">,or <python|a=1;a=a+2>) are sent to <python|compile()> and in doing this,the return value of the last statement is lost. Therefore, in case you havemore than one expression you need to write to <python|os.sys.stdout> inorder to see the output inline: <script-input|python|default|a=1;a=a+2;printa|3> will print <script-output|python|default|a=1;a=a+2;print a|3> but<script-input|python|default|a=1;a=a+2|3> will print nothing. Thislimitation may be fixed in the future.Additionally, after selecting <menu|Document|Scripts|Python>, you may alsoinsert <em|executable input fields> using <shortcut|(make-calc-input)> or<menu|Insert|Link|Executable input field> (again, pressing <key|return>alternates between evaluated and unevaluated input). These have identifiersassociated which may be referred to in other fields by inserting a<em|field reference> using <shortcut|(make 'calc-ref)> or<menu|Insert|Link|Field reference>. Plain <em|input fields> are alsoavailable using <shortcut|(make-calc-inert)> or <menu|Insert|Link|Inputfield>. This allows for dynamic documents which automatically run thescripts after changes to the referred fields. See ``Plug-ins as scriptinglanguages'' in the <TeXmacs> documentation for more on this topic.<tmdoc-copyright|2004, 2014|Adrián Soto|Miguel de Benito Delgado><tmdoc-license|Permission is granted to copy, distribute and/or modify thisdocument under the terms of the GNU Free Documentation License, Version 1.1or any later version published by the Free Software Foundation; with noInvariant Sections, with no Front-Cover Texts, and with no Back-CoverTexts. A copy of the license is included in the section entitled "GNU FreeDocumentation License".></body><\initial><\collection><associate|page-type|letter></collection></initial>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。