Generate Your Text Files With Python Using Cog
January 13th, 2022
50 mins 32 secs
About this Episode
Developers hate wasting effort on manual processes when we can write code to do it instead. Cog is a tool to manage the work of automating the creation of text inside another file by executing arbitrary Python code. In this episode Ned Batchelder shares the story of why he created Cog in the first place, some of the interesting ways that he uses it in his daily work, and the unique challenges of maintaining a project with a small audience and a well defined scope.
- Hello and welcome to Podcast.__init__, the podcast about Python’s role in data and science.
- When you’re ready to launch your next app or want to try a project you hear about on the show, you’ll need somewhere to deploy it, so take a look at our friends over at Linode. With the launch of their managed Kubernetes platform it’s easy to get started with the next generation of deployment and scaling, powered by the battle tested Linode platform, including simple pricing, node balancers, 40Gbit networking, dedicated CPU and GPU instances, and worldwide data centers. Go to pythonpodcast.com/linode and get a $100 credit to try out a Kubernetes cluster of your own. And don’t forget to thank them for their continued support of this show!
- Your host as usual is Tobias Macey and today I’m interviewing Ned Batchelder about Cog, a tool for generating files or text from embedded Python logic
- How did you get introduced to Python?
- Can you describe what Cog is and the story behind it?
- What are the use cases that you initially created Cog to address?
- What were the shortcomings or extraneous overhead that you encountered in tools such as Jinja, Mako, Genshi, etc. that led you to create a new tool?
- What was your path from a quick and dirty script that suited your own purposes to turning it into a niche open source project that was general and stable enough for the broader community?
- One of your claims to fame is your role as the maintainer for coverage.py. How has your experience managing such a widely used project translated to the relatively small and low traffic project like Cog?
- Can you describe how Cog is implemented?
- How did you approach the design of the syntactic elements for embedding Python code into a host file?
- What is the workflow for someone using Cog to generate all or parts of a file?
- How does the introduction of third party dependencies impact the viability and utility of Cog as compared to other templating systems?
- What are the most interesting, innovative, or unexpected ways that you have seen Cog used?
- What are the most interesting, unexpected, or challenging lessons that you have learned while working on Cog?
- When is Cog the wrong choice?
- What do you have planned for the future of Cog?
Keep In Touch
- McFly Command Line History Tool
- Go for a walk
- Thank you for listening! Don’t forget to check out our other show, the Data Engineering Podcast for the latest on modern data management.
- Visit the site to subscribe to the show, sign up for the mailing list, and read the show notes.
- If you’ve learned something or tried out a project from the show then tell us about it! Email email@example.com) with your story.
- To help other people find the show please leave a review on iTunes and tell your friends and co-workers
- Boston Python
- Lotus Notes
- Cheetah Template Engine
- Unix Philosophy
- Hungarian Notation
- Jupyter Notebooks
- GitHub Profile ReadMe
- Ned’s GitHub Profile
The intro and outro music is from Requiem for a Fish The Freak Fandango Orchestra / CC BY-SA