Python: A Long and Winding Road

I first encountered Python several years ago when working on Oracle Virtual Directory, part of the identity solution supporting a then new Oracle-based web portal. Oracle Virtual Directory, or OVD, was designed to abstract multiple identity stores, whether they were native identity stores (LDAP) or not (databases), and make them seem like a unified directory. One of the “killer” features was the ability to merge, manipulate and otherwise bend the data to the clients’ will. To achieve this, one of the main weapons in OVD’s arsenal was a built-in scripting language that was a subset of Jython, the Java implementation of Python.

The use of Python as a scripting language proved very powerful, and while unfortunately my code didn’t make it into production (due to the instability of OVD itself and not the code), it left an impression on me. I picked up Mark Lutz’s Learning Python, 3rd Edition from O’Reilly (now up to a respectable 5th edition), with every intention of getting to know this language better. Alas, life intervened, as it does, and I only ended up a handful of chapters in before other distractions took hold.

What’s Old is New Again

Around the tail-end of 2014 I was casting about for something new to learn, and came across Programming for Everybody (Python) from Charles “Dr. Chuck” Severance on Coursera. The course was very beginner, non-technical-background oriented, because for Everybody, but I don’t code often in my day job and wanted to ease back in any way. I really enjoyed the course and ended up enrolling in the Python for Everybody Specialization. It is a series of courses introducing you to Python, data structures, access web data (lots of JSON), and databases via SQLite. It culminates in a Capstone project where you have to combine what you’ve learned into a cohesive whatnot.

What did I come up with? A little program I called Get Sirius, which builds Spotify playlists based on now playing information on the SirusXM website. The now playing information is grabbed from an associated JSON file on the SiriusXM website, the song checked against a local SQLite database to see if it’s a duplicate, and if not it’s logged in SQLite and then fired off as a web request to an IFTTT Maker Channel that turns around and adds the song to a Spotify playlist.

In less than 100 lines of code. Including white space and comments. Yeah. I was hooked all over again.

What’s the Appeal?

In a line:

print "Hello World!"

What if that line, or lines, comes from a text file?

for line in open('file.txt'):
    print line

Look how simple that is. How straight forward. A text file is opened and iterated through line-by-line, printing the contents out to the screen. In two lines of code. Two, easily read and understood, lines of code.

Because white space, especially indentation, must be used to end up with a usable program, Python code is actually easy to read. No tracking down curly braces or semicolons. For maintainability, or even starting out learning how various Python programs work, this is invaluable. Python has, effectively, embedded a culture of predictable communication into its specification. Powerful stuff.

Not to mention the abundant Python ecosystem, where there’s a module for practically everything. This let’s you focus on the core of what you’re trying to do, minimizing time spent coding and maximizing time spent Making Things Happen™.

The Road to ‘Hello World!’ is Paved With Good Intentions

I want to learn more about Python and what I can do with it. I’ve picked up a few self-paced online courses which aim to help you learn by doing. The fantastic Talk Python to Me podcast acts as my weekly Pythonic anchor whether I’ve been able to get any coding time in or not. And I’ve got my eyes firmly fixed on VMware vSphere. Be wary, vSphere, you will be tamed with Python.

Watch this space.

Featured image photo by yukop

Dee Abson

Dee Abson is a technical architect from Alberta, Canada. He's been working in the field of technology for over 20 years and specializes in server and virtualization infrastructure. Working with VMware products since ESX 2, he holds several VMware certifications. He is a 9x VMware vExpert. You can find him on Twitter and Mastodon.

7 Responses

  1. @deeabson says:

    New Post: Python: A Long and Winding Road #code #vdm30in30

  2. @xinity_bot says:

    Python: A Long and Winding Road #General #Code

  3. @deeabson says:

    ICYMI: Python: A Long and Winding Road #code #vdm30in30

  4. @deeabson says:

    ICYMI: Python: A Long and Winding Road #code #vdm30in30 #ICYMI

  5. @rnelson0 says:

    RT @deeabson: ICYMI: Python: A Long and Winding Road #code #vdm30in30 #ICYMI

  6. @ankitmehta says:

    RT @deeabson: ICYMI: Python: A Long and Winding Road #code #vdm30in30 #ICYMI

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.