[Edu-sig] Lightning compiler and doctest quizzes
Andre Roberge
andre.roberge at gmail.com
Fri Apr 28 03:51:53 CEST 2006
Inspired by Jeffrey Elkner's earlier posts about using doctest based
quizzes to teach Python, I have done a fair bit of work on a little
app I wrote a while ago called "Lightning compiler". It can be found
on sourceforge, under lightning
(https://sourceforge.net/project/showfiles.php?group_id=125834).
Also, to quote from a previous message by Kirby Urner:
"Python needs a more developed interactive teaching module: show some
stuff, give students a command line, show more stuff, and so on."
While Lightning compiler is different from the specific example Kirby
gave (about the J language environment), I think it can be very useful
tool in that kind of context.
@Kirby: I'd be very curious to get your opinion of LC.
Lightning Compiler (LC) is a wxPython based app. LC's purpose is to
provide a friendlier environment to tests Python code snippets than
the Python interpreter. It does include an interpreter (pyShell) but
it is most likely to be used for its editor. You can execute the code
that appears in the editing window and the output is redirected to an
output window. raw_input() and input() are handled via dialogs. The
basic layout (output window to the side or below the editor window) is
customisable. Also, every command can be executed either by pressing
a button or through a keyboard shortcut.
You can also select part of the text (code) that appears on the editor
window and execute it. If some text is selected, LC automatically
uses it to be executed; otherwise it execute the entire window
content.
You can also ask LC to treat the code as a module and tests it with
doctest by pressing a button (or keyboard shortcut). LC creates a
module with the content of the editing window (or the selected part of
it) and appends the lines:
#
import doctest
doctest.testmod()
#
before running it.
It can also use tests appearing in an external file, automatically adding
the required commands, something like:
#
import doctest
doctest.testmod()
import unittest
suite = doctest.DocFileSuite('some_file_queried_via_a_dialog')
unittest.TextTestRunner("some verbosity level").run(suite)
#
You can "drag and drop" a python script into the editing window,
instead of having to go through the open dialog.
LC comes in a zip file with a sample app, showing how it can be
embedded in other applications, as well as a sample script with
doctests and a text file containing additional doctest based tests.
For those that have tried LC before, a major change (in addition to
the doctest feature) is the possibility to have more than one editing
tab (as many as you want :-).
Since LC uses wxPython, it can not be run with a basic Python
installation. If there is some interest, I might try and adapt it so
that it could use Tkinter instead as an option. This would probably be
required if one wanted to use it with VPython for example. However, I
have no experience with Tkinter. Any help would, of course, be
appreciated :-)
Thinking further about what Jeffrey suggested (having a collection of
doctests online), I have been thinking about adding an option where
one could fetch a code snippet (doctest) from a url. This would be
fairly easy to implement. However, until there exists a significant
collection of such code snippets, there is little need to consider
adding this feature. As it is, one can always do a "cut-and-paste"
from a browser to the editing window and work from there.
Finally, as usual, I welcome any comments about this little app. Note
that it is not intended as a complete IDE.
André
More information about the Edu-sig
mailing list