I’ve found Python is a useful skill in the workplace. It took me a little while to learn it, but it turned out to be easier than I thought it would be. Here’s why I learned Python, and I think anyone who works in IT should at least consider learning it.
Back in 2003 or 2004, I got pulled into a deployment project that was running behind. They had a January 1 deadline, and it was Christmas, and they weren’t going to make it. My manager, who for whatever reason didn’t want me on the project, asked me what I could do.
Many of the tasks on the list were time-consuming to do manually, but not difficult to script. By scripting it out, I was able to finish work in a matter of hours that had bogged the team down for the last couple of months.
I took this skill along to my next job. That manager hated my scripts. But it allowed me to ensure all my work was identical. And like I told him, if there was a mistake, all of them had the same mistake. Unwind the mistake, change the value to what it should be, and we could rapidly recover.
For years after I left that job in 2009, that manager would make comments like, “Dave never had any trouble doing that.” That’s because Dave had scripts to do most of the things he asked, or could quickly modify an existing script to do whatever he was asking for that day.
Now, that was 2009. My scripts were clunky batch files, because I couldn’t load anything else onto the systems in question. Today, automation is a big buzzword, and many automation tools, like Demisto, use Python.
But even if you don’t have a tool like Demisto, Python has advantages over the way I used to do things. Its data processing capabilities are much richer. And the code is easier to understand.
Ease of learning
If you’ve ever programmed in any other language, Python is pretty easy to pick up. It’s less cryptic than languages like Perl and C. You can write pretty convoluted code in Python if you try, but generally speaking, Python forces you to code fairly clearly, using things like indentation to enforce readability as well.
I generally use Python to extract data from web-based applications via API. I frequently start with an example from the vendor, then build onto its capabilities. By parsing the JSON or XML output into a data structure, you can navigate the data structure to find what you need, then perform some other action. That could be sending the data to another application, or sending a command to the same application via API.
They don’t have to be elaborate. I have scripts I use almost every week that are fewer than 20 lines long. I also have one that’s more than 2,000 lines long and counting, but that script started simply, then just built onto itself as time went on.
Why should I learn Python when so many jobs require Powershell?
Many job listings ask for Powershell, not Python. But you can find job postings requiring one or the other, or just Python. I prefer Python because it’s cross platform and has been cross-platform longer than Powershell. I tried to learn Powershell in 2005-2006 and found it cumbersome. I did manage to write a few useful scripts here and there, but when I went to learn Python, I wrote a larger number of scripts in a much shorter period of time.
Even if you need Powershell, I’d suggest learning Python first. Get the concepts down in Python, then Powershell will be easier to learn. And then you know two languages, not just one.
Proving you know Python
Some hiring managers expect Python. A smart one will ask in a job interview for you to demonstrate some aptitude. Showing a manager a script you wrote in a previous job is a bad idea. If you wrote it on company time, it belongs to the company, not to you, unless the company releases it to you, or releases it under an open source license of some kind. Some managers will assume you will take your scripts with you again if you did this time.
So here’s an idea for you.
Try writing a script that pulls yesterday’s weather (or a week ago’s weather) from wunderground.com and puts the data into a Powerpoint slide using the PPTX library. It’s not a terribly useful script. But you can easily pre-empt that comment. When you show the script, point out right away that it does date logic, it pulls data, then dumps the data out in a useful format. If you can pull data from wunderground.com and put it in a presentation, that means you can pull data from other tools and create automated metrics.
And since it’s pulling data from Weather Underground, it’s obvious it’s your property, not the property of a former employer.
Hiring managers like it when they see a candidate who can have an immediate impact on a team. Being able to demonstrate skill in Python gives you that edge.