Stefan, Have you considered a templating engine such as Jinja or Cheetah?
http://jinja.pocoo.org/2/ www.cheetahtemplate.org/ They should be able to handle a lot of the parsing and pairing of variables in a template that you're attempting. Basically, you use template syntax (as you seem to have created on your own), and then simply fill in those variables by passing in a "context", or dictionary of objects. The great thing about these templating engines is that they come pre-packaged with standard looping constructs, so you don't have to reinvent that wheel. I've been tinkering with Jinja and can't say enough about it. HTH, Serdar _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor