Teaching Programming

Ed Keith e_d_k at yahoo.com
Tue May 4 11:43:22 EDT 2010


--- On Tue, 5/4/10, Stefan Behnel <stefan_ml at behnel.de> wrote:

> From: Stefan Behnel <stefan_ml at behnel.de>
> Subject: Re: Teaching Programming
> To: python-list at python.org
> Date: Tuesday, May 4, 2010, 11:33 AM
> Ed Keith, 04.05.2010 15:19:
> > --- On Tue, 5/4/10, Stefan Behnel wrote:
> >> Ed Keith, 04.05.2010 14:15:
> >>> Python is a great language to write in
> (although I do
> >>> wish it did a better job with closures). But
> it is a PITA to
> >>> generate code for!
> >> 
> >> Interesting. Could you elaborate a bit? Could you
> give a
> >> short example of what kind of document text you
> translate
> >> into what kind of Python code, and what the
> problems were
> >> that you faced in doing so?
> > 
> > The program is written using itself. If you click on
> the link above you
> > will see an HTML file that fully describes the
> program.
> 
> I did. I find it a bit hard to read due to the block
> splitting (basically like 'include' based spaghetti
> programming), but so far, the actual code that does the code
> merging looks pretty simple and I can't figure out where the
> "PITA" bit is on that page. That's why I asked.
> 
> Stefan
> 
> -- http://mail.python.org/mailman/listinfo/python-list
> 

The PITA is having to keep track of the indentation of each embedded chunk and summing it for each level of indentation. This requires a fair amount of bookkeeping that would not otherwise be necessary. 

The original prototype simply replaced each embedded chunk with the text from the chunk definition, all indenting information was lost. It worked for most languages, but not Python.

In testing the program I used two languages, Python and J. I figured if I could make both of them work I would not have any problem with anything else.

    -EdK

Ed Keith
e_d_k at yahoo.com

Blog: edkeith.blogspot.com



      



More information about the Python-list mailing list