Brushing up on Python: Because Why Not?

Hi Everyone! It’s been a long while since I’ve actually posted something on my site, and about as long since I’ve updated everything else on here. Since I last posted, I’ve finished earning my Masters Degree, and have just completed one year as a Software Engineer at Logitech’s Newark, CA office. It’s a really rewarding job, and I’ve learned a lot so far. However, I’ve found that my most noteworthy (and non-confidential) projects are the ones I work on outside of work.

I pride myself on keeping up-to-date on the newest trends in Software Engineering. A co-worker of mine recently created some scripts that automatically create builds of our codebase, using Python. As a result, I decided to read up on the language in general. From what I understand, it’s a dynamic programming language that allows for compact lines of code, and is referred to as a “scripting” language. Like a lot of “general purpose” programming languages, it can be used for everything from scientific computing to machine learning to client-server interactions. One thing that initially interested me about Python was that the language was basically split into 2 versions, Python 2 and Python 3. The differences, from what I saw, basically came down to the fact that Python 2 is not being actively developed on, plus Python 3 is a little more streamlined and well-supported since it is the “newer” version. The only real reasons you would use Python 2 is that you need to write Python code in conjunction with software that only supports a certain version of Python 2, or if you need to use a specific version of Python for whatever reason. Good stuff.

So, I got the idea of Python. Its a script-y, higher level language, and there are 2 versions, but you should probably just use Python 3 if there’s no reason not to. So, how do I go about learning Python? Or any programming language, for that matter?

Well, my first step was to run through the Python tutorials at hackerrank.com. I’ve had good experiences with the platform in the past, and I decided to go through the Introduction section available for Python. Having the ability for a website to read your code and test its validity is super nice. Though it did teach me the basics, at one point the questions turned into problems that I didn’t feel like I had the building blocks for yet (as in, “here is a tuple object” into “parse a set of lines, calculating the average for each line, and then retrieving an average for one entry, rounding this answer to 2 decimal places)”. Though these problems were doable, especially for someone who is familiar with the art of programming, I didn’t feel like I had learned the tools to solve the problem efficiently and compactly, the way a “proper” Python programmer should. I ended up writing something like this:

test1

“I mean, it’s a little wordy, but it works…”

 

Then I looked on the Discussion Board for this question, and found this:

 

test2

“Oh wow. That is way better.”

Though the concept is the same, the code I found seemed to be actually written be a real Python engineer, instead of a guy using Python, but writes code primarily in C++. One thing especially of note, besides the code’s cleanliness, is less use of assigned variables except for ones that are needed (I used more “Intermediary” variables), and the great use of Python’s “Built-In” functions, such as map() and sum(), which I didn’t use in my code because I was not yet aware of them. I felt like this was a little jarring. I looked for other approaches to learning this new language.

My next approach to learning this language was to instead install the Python add-on for Visual Studio, and run through the Python documentation as a tutorial. So far, this has felt like a more well-thought-out approach, since everything builds on previous knowledge, and the tutorial begins with an overview of the language, instead of “Here’s hello world”. I can’t really attest to how this has worked out post-mortem-style, since I am still working through it. So far, I think it works better for me personally. I work through it for about an hour every day, since I find that I respond well to routine and structure in learning. We will see how it goes!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s