On Mon, 21 Oct 2013 21:55:26 -0400
gatesphere <[email protected]> wrote:
> Keep pushing! Here's another step-by-step:
>
> 1) Create a node, headline named "@file myfile.py" (henceforth "node
> A") 2) In the body of that node, put the following:
> @language python
> << docstring >>
> @others
> if __name__ == '__main__':
> main()
> 3) Create a child node of "node A", headline named "<< docstring >>"
> 4) In the body of that node, type this:
> '''
> This is a docstring. It explains what this python module does.
> '''
> 5) Create a child node of "node A", headline named "main"
> 6) In the body of that node, type this:
> def main():
> print "hello, world!"
> 7) Save your .leo. It should create myfile.py automatically.
> 8) Open myfile.py in an external editor. Observe the structure. Run
> it with a python interpreter if you want to make sure it's valid.
> 9) Experiment more!
Done. Worked. Made a Python file called myfile.py that did the right
thing and said the right thing in pydoc.
However, I could not run it with Ctrl+B. Is there an either-or choice
between putting it in a file and running it from a Ctrl+B?
>
> > Then I tried having three subnodes, each with a different g.ex(),
> > and seeing if I could Ctrl+B their parent. No dice. However one does
> > functional decomposition in Leo, it takes quite a bit of reading to
> > find out.
> Agreed. A third step-by-step is in order, perhaps?
>
> 1) Create a node, headline anything you want.
> 2) In the body write the following:
> @language python
>
> x = 1
>
> @others
> 3) Create a child node of that node, headline anything you want.
> 4) In that node's body, write the following:
> g.es('test# ', x)
> 5) Clone that node a few times so that it is it's own sibling (i.e.
> hit Ctrl-` with the node selected a few times)
> 6) Ctrl-B the parent node (from step 1). Observe the magic!
Done. It printed "Test# 1". But only once. So then I added a second
second level node that printed "Steve was here", and sure enough, it
printed both "Steve was here" and "test #1".
It appears to me that Leo won't execute multiple clones.
I was able to set x in one node and print it in another. I was able to
increment in consecutive nodes and have it come out right.
> That example uses clones to show how they can be used to reduce code
> repetition.
I was unable to get several clones all execute.
Thanks,
SteveT
Steve Litt * http://www.troubleshooters.com/
Troubleshooting Training * Human Performance
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/groups/opt_out.