A month or so ago I saw this RSS reader project at Mouse vs. Python. It was the first GUI-based Python tutorial program I ran across that had a real-world (though simple) use. I guess I’m still fascinated by actually being able to program and code a graphical interface. Yes, I’m used to Microsoft Access and VBA, but that’s still a graphical piece of software being used to build graphical objects. With Python, I can sit in front of a dark, boring command-prompt window, enter some monospaced, arcane spells in Tkinter, wxPython, or what have you, and conjure up colorful windows and widgets like a sorcerer. I’ve been eager to partake of this magic since cranking out my first post-Code Academy project (a.k.a., the Python equivalent of “See Jack Run”, literally), and here was a chance to see a “real” Python based GUI app in action, and study and tinker with its code. Therefore, once I saw this, I couldn’t wait to get in front of my laptop and take it for a spin.
Little did I know a coding epiphany was on the way. Actually, two.
As can be seen from Mike’s code, this app requires a add-on toolkit called “feedparser.” I had a devilish time getting that thing to function. It seemed to install OK, using “easy install”, yet it stumbled over the “import” statement, giving me an error along the lines of “line 154 – no module named request.” I don’t remember it exactly, and since I didn’t know then I’d be writing about the experience, didn’t save the exact error message.
Regardless, like a good coding newbie, I didn’t panic and cry for help…I Googled it first. Well, as I recall, the only hit that even seemed to approximate my situation was a Python forum in Chinese. Dauntless, I ran it through Google Translate and did my best to decipher the somewhat broken English it spat out. Still no help. I started to get frustrated. All I wanted to do was try this cool RSS app, and here I was, spending most of a day on an uncooperative dependency that was tripping up the code on its very first line. “This isn’t what I planned!”, I growled to myself.
Exactly. Because that, folks, is what I realized is a major part of a coder’s life: confronting and solving unexpected problems, and learning (even against my will) in the process. Sometimes my biggest coding project will be something unexpected that interrupts the project I’m really excited about, and I will have to digress.
I realized that if I can’t handle such digressions, then I won’t be able to handle being a coder.
And guess what? I handled it.
You see, I recalled that there was another popular method for installing Python packages: something called “pip”, which one of my earlier tutorials had told me I needed, and therefore, I had installed it. So, just for kicks, I went to my command prompt and typed: “pip install feedparser.”
That did it! Now the code was off and running, and a great big RSS reader GUI window materialized before my eyes! All I had to do was click the “Get Feed button…”
Crash. Another error. Now the code told me it needed an object called “RSS”, which was not defined. So, I searched and searched through the code, and couldn’t find it. I tried lowercasing “RSS” in the offending statement, and other random, clueless thrashing about, to no avail. Alas, I was beaten. So I broke down. I asked Mike for help.
He was kind and patient, suggesting I re-check the code I’d copied and pasted from his blog. And there, lo and behold, was an entire chunk…the ‘RSS’ class definition..that I had neglected to copy and paste! I’d probably let my cursor get ahead of my scroll wheel, or something like that. I pasted it in, and..eureka! There was the RSS article list and summary on my left, and a glorious in-app web browser in the big window on the right! I did it! I’m magic! (or, at least, I was able to get Mike’s magic to obey a wizardly newcomer).
So, here was the second epiphany: sometimes, after giving a challenge my best effort, I need to know when to humble myself and get help. Thankfully, in the Python world, there are plenty who are ready to do so.