Monday, September 24, 2018

Learning Python

Several months ago I embarked on a project at work that made me question my decisions in life.  Well, ok, that's a bit melodramatic.  But it definitely made me question my choice of programming languages.  I thought I had on my hands a simple, straight forward problem.  Loop a couple arrays, can a handful of command line utilities.  Oh I know, I'll use shell script (bash)!  It was not long before I was asking what I'd gotten myself into.

I was too far in to turn back, and I ended up with a 1000+ line monstrosity over a handful of files.  I hated bash... seeing my kludgy attempts at modularity made me want to claw my eyes out. The first few lines of every function were devoted to parsing the parameters. It was an unholy mess, and I knew I needed something better.  I knew I needed Python (ironically, I ended up rewriting it in Java, funny how things work out)...

I put together this post to describe my experience with several learning resources I took advantage of.


Google Python Class


I'd heard of a class put together by Google for learning Python, and it wasn't hard to find.  I thought it would be a really great resource, and while it wasn't terrible, it was created 8 years ago and it's showing its age.  It somewhat straddles the line between "beginning programming" and "beginning Python"... what I mean is that a fair bit of the content it pretty basic to the programmer experienced in other languages.  While I suppose it's common to introduce a language by working up through the basics, much of it didn't necessarily feel like a great use of time.



HackerRank Python track


HackerRank has a Python track, much like it has tracks for other highly popular languages.  I am a big fan of hands on learning, and the bite size challenges are easy to consume.  The small chunks can be a bit of a drawback as well, though, since you can't really get familiar with how to structure larger Python projects just by cranking through small coding challenges.  All in all, though, it is a great way to learn the basic building blocks of the language.

As of this writing there are 115 challenges in this track, and none of them are excessively difficult. They cover a broad variety of Python topics, touching on numpy, itertools, list comprehensions, and more.  After solving a problem my own way, I almost always learned something by visiting the discussion page and seeing how others approached the problem.

Expect to put in some hours finishing them all, but I found it to be a worthwhile learning effort. As a reward, you'll be tied with about 500 other intrepid Pythonistas as a #1 ranked Python guru. Don't you feel smarter?





PluralSight Python path


The PluralSight courses are grouped into beginner, intermediate, and advanced, with 2 or 3 courses in each group.  Beyond the "path" courses are other more specialized courses.  There isn't the wealth of content here as there is in, say, the C# path (which is 60+ hours), but it's up to date content and well produced.  

The beginner level courses are definitely targeted at those not just new to Python, but programming in general.  They cover some high level "about Python" kind of material, and basic keywords, syntax, and idioms.  If you are an experienced programmer new to the language it's still good to know, but it gets a bit played out rather quickly.

  • Python The Big Picture: Little technical content, more of a sales pitch for Python
  • Python Getting Started: Quick overview, covers built in types, functions, lambdas, OOP concepts, and a quick dirty example of a web app with Flask
  • Python Fundamentals: More in-depth coverage of the basics (String, Collections, Modularity, Objects, Exception Handling, Iterables, Classes, Files). The first in a trilogy of Python courses (Along with Python Beyond the Basics and Advanced Python).
The three intermediate level courses are the meat and potatoes of this learning path.  The "Beyond the Basics" course goes deep into the technical minutia of working with Python, weighing in at 7+ hours.  The "Toolkit" course includes useful information for day to day development. Finally, the unit testing course examines the idiosyncrasies of TDD in Python, which coming from Java I found incredibly helpful.
  • Python Beyond the Basics: Deep dive on Python (modules, packages, closures, decorators, inheritance, type protocols, and revisits many of the concepts from Fundamentals in more depth)
  • Python Developer's Toolkit: Package management, virtual environments, Pylint, debugging, documentation generation, and distribution.
  • Unit Testing with Python: Covers using unittest, pytest, and doctest.
The "advanced" courses are a real mixed bag. "Advanced Python" is excellent, covering some really esoteric Python features that, while not likely needed often, are incredibly powerful and doubtless very useful when the appropriate situation arises. The "Web2Py" course, on the other hand... is rubbish.  Bush league basic MVC framework stuff.
  • Advanced Python: loop-else constructs, bytes, custom attributes, descriptors, metaclasses, abstract base classes. One of the notable things for me with this course was the degree to which you could customize the entire object life cycle. It's like I could redefine what the "new" keyword in Java does, it was something else.
  • Full Stack Web Development with Python (WEB2PY): gag.

I found the skill assessment test an interesting gauge of where I was at.  I didn't rate as high on Python as I have in Java and Javascript, but hey, they can't all be winners. I last took the assessment before finishing all the HackerRank challenges. I guess I could try it again, but it seems kinda pointless at the moment. I think I'd rather be playing Terraria:










No comments:

Post a Comment