Leo + Python:最终的脚本工具 [英] Leo + Python: the ultimate scripting tool

查看:76
本文介绍了Leo + Python:最终的脚本工具的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在这里说一些(实际上不止一些)关于一些

我最近关于Leo和Python的互动的发现。

如果你不想听到发明家对他的工作很着迷,请感觉

免费阅读:-)


至少有三,没有四,没有五,没有六,没有七个理由为什么Leo

和Python一起工作得很好。大多数是新的(在我看来)与狮子座的4.1

版本。前几个原因似乎并不多。当你看到这个外观完全是误导性的:

功能的组合非常强大。


保持个别帖子较短我将在回复中列出这7个理由和

结论。发表这篇文章。


爱德华

------------------------- -------------------------------------------

Edward K. Ream电子邮件: ed*******@charter.net

Leo:包含轮廓的文学编辑器

Leo: http://webpages.charter.net/edreamleo/front.html

----------------------- ---------------------------------------------

I would like to say a few (actually more than a few) words here about some
recent discoveries I have made concerning the interaction of Leo and Python.
If you don''t want to hear an inventor enthuse about his work, please feel
free not to read further :-)

There are at least three, no four, no five, no six, no seven reasons why Leo
and Python work so well together. Most are new (in my mind) with the 4.1
release of Leo. The first several reasons may not seem like much. As you
will see, this appearance is completely misleading: the combination of
features is incredibly powerful.

To keep the individual posts shorter I shall list these 7 reasons and a
conclusion in "replies" to this posting.

Edward
--------------------------------------------------------------------
Edward K. Ream email: ed*******@charter.net
Leo: Literate Editor with Outlines
Leo: http://webpages.charter.net/edreamleo/front.html
--------------------------------------------------------------------

推荐答案

为什么Leo和Python一起工作得很好:


1.你可以直接从任何地方执行Python脚本Leo大纲。


Leo大纲中任何节点的正文可能包含任何Python脚本。

执行脚本命令在原始环境中执行此脚本。

但是,从任何脚本_中获取访问权限到所有
$是微不足道的。 b $ b目前大纲中的数据。例如:以下脚本将所有

打印成嵌入脚本的大纲中的标题。


来自leoGlobals import c#获取对所有数据的访问权限在目前的大纲中。

c = top()#获取指挥官与最上面的轮廓相关联。

v = c.rootVnode()#获取轮廓的根节点。

而v:

.. .print v.headString()

... v.threadNext()#移动到threading中的下一个节点。订单。


就此而言,脚本可以访问硬盘驱动器上任何位置的任何数据,或者

网上可用的所有数据。你知道,当然,这是无辜的。事实上以后会很重要。


因此,很容易在
Leo中试验新的脚本。

Edward

------------------------------------ --------------------------------

Edward K. Ream电子邮件: ed ******* @ charter.net

Leo:包含轮廓的文字编辑器
Leo: http://webpages.charter.net/edreamleo /front.html

---------------------------------- ----------------------------------
Reasons why Leo and Python work so well together:

1. You can execute Python scripts directly from anywhere in a Leo outline.

The body text of any node in Leo outline may contain any Python script. The
Execute Script commands executes this script in a pristine environment.
However, it is trivial to get access, _from within any script_, to all the
data in the present outline. For example: the following script prints all
the headlines in the outline in which the script is embedded.

from leoGlobals import c # Get access to all data in the present outline.
c = top() # Get the "commander" associated with the topmost outline.
v = c.rootVnode() # Get the root node of the outline.
while v:
...print v.headString()
...v.threadNext() # Move to the next node in "threading" order.

For that matter, scripts can access any data anywhere on your hard drive, or
all the data available on the web, for that matter. You knew that, of
course, but this "innocent" fact will be important later.

As a result, it becomes very easy to experiment with new scripts from within
Leo.

Edward
--------------------------------------------------------------------
Edward K. Ream email: ed*******@charter.net
Leo: Literate Editor with Outlines
Leo: http://webpages.charter.net/edreamleo/front.html
--------------------------------------------------------------------


原因为什么Leo和Python一起工作得很好:


2. Leo'的轮廓是组织脚本的完美工具。


这是狮子座大纲的组织力量的直接结果。

但是,它仍然让我感到惊讶。对于

的例子,目前,Leo有一个Scripts。菜单也可以组织脚本。

很可能狮子座的单独概述,以及我将很快讨论的功能,将使脚本菜单变得冗余。


爱德华

----------------------------- ---------------------------------------

Edward K. Ream电子邮件: ed*******@charter.net

Leo:带有轮廓的文学编辑器

Leo: http:// webpages.charter.net/edreamleo/front.html

--------------------------- -----------------------------------------
Reasons why Leo and Python work so well together:

2. Leo''s outlines are the perfect tool for organizing scripts.

This is an immediate result of the organizational power of Leo''s outline.
However, it continues to surprise me how powerful this really is. For
example, at present, Leo has a "Scripts" menu that also organizes scripts.
It may well be that Leo''s outlines alone, combined with features that I
shall shortly discuss, will make the scripts menu redundant.

Edward
--------------------------------------------------------------------
Edward K. Ream email: ed*******@charter.net
Leo: Literate Editor with Outlines
Leo: http://webpages.charter.net/edreamleo/front.html
--------------------------------------------------------------------


为什么Leo和Python一起工作得很好:


3.脚本可以使用Leo'轮廓的结构。


这是第一个大的之所以结合Python&狮子座是壮观的。如上例所示,脚本可以访问Leo大纲中任何节点的

标题或正文。因此,脚本可以使用大纲的_structure_来访问a)其他脚本,b)

exec或eval的代码片段或c)其他数据。


它变得更好......


爱德华

----------- -------------------------------------------------- -------

Edward K. Ream电子邮件: ed ******* @ charter.net

狮子座:带轮廓的文盲编辑器

狮子座: http://webpages.charter.net/edreamleo/front.html

--------- -------------------------------------------------- ---------
Reasons why Leo and Python work so well together:

3. Scripts may use the structure of Leo''s outlines.

This is a first "big" reason why the combination of Python & Leo is
spectacular. As shown in the example above, scripts may get access to the
headline or body text of any node in a Leo outline. Therefore, scripts may
use the _structure_ of the outline to gain access to a) other scripts, b)
fragments of code for exec or eval or c) other data.

It gets better...

Edward
--------------------------------------------------------------------
Edward K. Ream email: ed*******@charter.net
Leo: Literate Editor with Outlines
Leo: http://webpages.charter.net/edreamleo/front.html
--------------------------------------------------------------------


这篇关于Leo + Python:最终的脚本工具的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆