Cog, my templating and code generation tool, seems to be like the little engine that could. I wrote it years ago to bring a little Python power to a non-Python job. But then it was unexpectedly useful while preparing my slides for PyCon this year. I did a lightning talk explaining why (I start at about 8:00 minutes in).

One of the things I didn't expect when I released Cog was that people would take the concept and port it to other languages. There are implementations for PHP, Ruby, and Perl. And now, Doug Harriman has written another, so you can Cog in Matlab. I don't know anything about Matlab, I didn't realize this was even a sensible idea, but now it's real.

When I look at Cog now, I see things I'd like to change about it. Maybe there will be a more modern implementation some day. But it does its job well now. If you have text files that you want to do a little bit of processing on, look into Cog, people seem to like it.

tagged: » 3 reactions

Comments

[gravatar]
Doug Hellmann 10:28 AM on 12 Apr 2011

I love Cog, and couldn't have written all of those articles for PyMOTW without it.

[gravatar]
John Cavanaugh 6:46 PM on 12 Apr 2011

Ned,

I needed something similar a while back and I wrote a cmdline (j2.py) wrapper for Jinja2. Its now in heavy use in our build systems here as a text template compiler tool. I submitted it back to the jinja authors but it didnt go anywhere. I should just go put it up on bitbucket.

--
John Cavanaugh

[gravatar]
Michael Chermside 6:28 AM on 14 Apr 2011

Ned:

For the sake of learning something about design, I would be interested in hearing some of the things you would change about Cog. It's small enough and simple enough to be a good case study in design.

Add a comment:

name
email
Ignore this:
not displayed and no spam.
Leave this empty:
www
not searched.
 
Name and either email or www are required.
Don't put anything here:
Leave this empty:
URLs auto-link and some tags are allowed: <a><b><i><p><br><pre>.