DEV Community

Manuel Vio
Manuel Vio

Posted on

Python: a resume programming language

tl;dr: I developed a DSL in Python to write my resume with, now it is both readable and executable.

a man at a wooden desk with folded arms and a displeased look


This resume cannot possibly work

Boring. That's what I thought when I read it a few weeks ago. I was contacted by a recruiter for a job opportunity and despite I turned down the offer I took a look at my resume to see if it was still in touch with the times (note to boss: don't worry, I don't plan to leave the boat anytime soon).

Well, boring was an euphemism. It could have been written as a restaurant menu, the vibes were the same. I felt that if that document was sent it would never make me look good as a job applicant, even if the recruiter was more interested to know my job history instead of dwell on the formatting details.

The first thing it needed was a graphical restyling, its layout was based on a template popped out of some obscure site many years ago and it showed all its age, so after a short search (nowadays there's plenty of resources on internet on how to write a good resume) I had a nice looking template to start my rewrite.

As soon as the editing went on my enthusiasm progressively decreased, although the document was getting a pleasant appearance.

Sure, it was rewritten in a more modern and coherent way, it was more "achievement oriented" and so on, but in the end it was still a mere pdf file and, most importantly, it was still boring to me.

a man at a wooden desk, facepalm in desperation


Nope, telepathy doesn't work either

My idea of a remarkable resume was set aside after a few days of unsatisfying researches and experimentation, and I was looking at a very interesting Python library (https://diagrams.mingrammer.com/) whose claim is that one could "draw a cloud system architecture in Python code", when something clicked: why shouldn't my resume be written as code as well?

Under the hood Diagrams makes use of runtime contexts and context variables to implement its DSL, so I borrowed the idea and started to write my own context managers. It turned out that I needed only one base class: any other class representing a document component would have been a specialization of this one.

As a document is nothing but a tree when it comes to its structure every portion in it can be ultimately represented by an implementation of this base node class. By taking advantage of its recursive nature one can easily define nested higher concepts such as Document, Section or Paragraph.

So, after a few iterations, I came up with my first resume as code which was something like this (the names have been changed to protect the innocent :) )

My work could have stopped here, with a bunch of hollow classes just to keep the syntax clean, and call it a day. It was real code, ant it was quite readable after all, but as you could have guessed I wasn't satisfied yet.

I wanted it to be not only executable, which it already was, but actually useful.

I wanted it to render itself.

The project already took a nonconformist path, thus an ordinary solution was simply out of the question, but the implementation had to be basic enough to be written without relying on a potentially heavy external ecosystem and just one library would have been the maximum acceptable dependency at this stage.

To keep things simple my choice fell on console output, but I knew Python has some nice libraries about formatting text in the terminal such as rich so my derived classes were refactored to implement console rendering.

Rich is another gem among Python libraries, it provides a great number of formatting tools such as (but not limited to) columns, panels, tables and trees, that can be composed to create very articulate, and colorful, layouts. I only scratched the surface of what Rich has to offer adapting the output to render tag groups, multiple columns, bulleted lists and it didn't take long before I got this result:

Resume console output

Now I have my resume written in real code, in a readable form, executable and self-rendering, which is what I was searching for in the first place: a non boring resume. Honestly I don't think any recruiter would actually read the code or run it, but I could still send a rendered output copy (or the good ol' pdf) if someone asks for it.

What I also got as a bonus is: a deeper knowledge of Python's context managers and a general purpose DSL class that could be extended and used in a number of cases beyond resumes.

The first revision of the base class is shown below, I'm thinking if it's worth creating a library around it given it's just a class after all. Maybe I could provide a couple of implementations in addition to the console one, and I already have some ideas (a few of them are, well, unusual…), I will publish them on Github eventually.

A renaissance woman with a book stares at you disappointed, facepalm


I only asked for your resume…

Top comments (0)