You know you're a Pythonista when..

Edward K. Ream edreamleo at charter.net
Sat Jun 14 17:12:02 EDT 2003


> I don't understand.  Could you elaborate?  For example, could you
> clarify whether you mean 'Leo source' or 'running Leo process' when
> you say 'Leo'?  Do you mean you work like one does with doctest: copy
> stuff from an interactive shell, and have them become permanent tests?

My old way was pretty stupid: I would develop Leo using Leo to edit Leo's
sources, LeoPy.leo.  Then I would _exit_ the copy of Leo that was editing
LeoPy.leo.  So if there were any problems that prevented Leo from running I
would have to correct those problems either using a backup copy of Leo or
using Idle.  Not only that, but LeoPy.leo is a big file, and it would take
15-20 seconds to reload it.

With the new way I never expose the copy of Leo that is running to the most
recent changes.  I test those changes in a _separate_ Leo outline running
the (new, changed) Leo code.  If the new copy of Leo crashes or has syntax
errors I still have the copy of Leo running that is editing LeoPy.leo.  And
I hardly ever _load_ LeoPy.leo; I just keep saving it.

This isn't anything new, and I feel really stupid for not having seen it
years ago.  And it _has_ tripled my productivity over "just" using Python
and Leo.

Maybe a "diagram" would help:

1. Leo(copy1) loads LeoPy.leo (I do this just once for each programming
session)
2. Make changes to LeoPy.leo and save LeoPy.leo.
3. Leo(copy2) loads test.leo (a much smaller file)
syntax error found.
4. Make changes to LeoPy.leo and save LeoPy.leo
5. Leo(copy2) loads test.leo
no syntax error, but changes needed.
6. Make changes to LeoPy.leo and save LeoPy.leo
etc.

I use a batch file called "t" to run test.leo.  I run this batch file in a
console window that stays open.  So in practice, the "diagram" above
becomes:

1. Leo(copy1) loads LeoPy.leo
2. Make changes to LeoPy.leo and save LeoPy.leo.
3. Type t in the console window to open test.leo in copy 2 of Leo
syntax error found.
4. Make changes to LeoPy.leo and save LeoPy.leo
5. Type t in the console window to open test.leo in copy 2 of Leo
no syntax error, but changes needed.
6. Make changes to LeoPy.leo and save LeoPy.leo
etc.

In other words, the "edit,compile,test" cycle becomes:
- edit and save LeoPy.leo.
- type t in console window.

I do this so often that using a short script name like "t" is actually
important.

HTH

Edward

P.S.  The stuff about "instant unittests" just happened naturally.  I would
run Python code in test.leo to test things out, and test.leo is a natural
way of organizing lots of cases.  So test.leo becomes a way of saving stuff
that should be made into official unit tests later.  What makes this work is
that Leo has a command that executes all the text of a selected node as a
Python script.

P.P.S.  Sure, I could fire up the second copy of Leo by double-clicking
test.leo.  But then when I exited test.leo I would have a useless console
window open that is running Python in -i mode, and I would have to close the
console window.  It's actually considerably easier to leave the console
window open and type t.

BTW, if such small matters make a difference I must be running a _huge_
number of tests in a short time, and that is exactly what happens.

P.P.P.S.  This workflow is probably why RMS never liked to exit Emacs.

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






More information about the Python-list mailing list