How do I, someone who just dabbles in Python and uses it for daily data handling tasks, become an expert in Python?
Anytime you learn a new skill, such as learning Python, you might feel anxiety about wether or not you are “ready”. You’re always looking around at this course or that, wondering “Is this any good?” or “Will I learn the right things?”
You want some way to hone your skills and “level up”. In school you might have a math class where your teacher would throw problem sets at you. You had lots of opportunities to work problem after problem, making corrections and getting (hopefully!) better. Now you know the basics of Python. You can even write a few Python programs by yourself. But, where to go from here? How can you take things to the next level?
An Excellent Way to Improve Your Python Skills
If you want to develop real skill in Python, you need to write as many Python programs as you can. You also need to get feedback about how effective your programs are. There’s no sense in writing defective garbage if you want to get better. You need some way to write lots of programs, get feedback, and be pushed to improve.
Luckily, there’s a superb place for this call Exercism.io.
Exercism.io is a web site that “provides countless small wins”. This is brilliant!
When you are working hard to improve, each win is a bit more momentum to push forward. Believe me, as you progress, you will need to be pushed a little harder to get better each time.
Exercism.io gives you a a lot of Python challenges – over 100 – for you to conquer. Each challenge comes with the tests already written. So in addition to learning how to solve problems in Python, you get to see how unit tests are built along the way. If you want to become an expert Python programmer then you must learn to write tests.
A Walkthrough of the First Challenge
Go ahead and sign up using your Github account. You’ll be asked to accept terms and conditions. Once you’ve done that, you should see a list of tracks. Find the Python track and click it.
Click the “Join the Python track” on the next screen.
You’ll see a dialog that asks if you want to use Mentored Mode or Independent Mode. Select Mentored Mode if you would like to a more structured experience where others provide feedback. Independent Mode is more of a work-at-your-own-pace model.
You will then see the page for your Python track.
Click on the “Hello World” section. You’re almost ready to install the command line interface (cli) tool. On the next page, look for and click the “Begin walk-through” option.
This will start a short series of steps that will guide you to installing the command line tool, which you will need to submit your answers and demonstrate progress.
To complete the installation, you will need your Exercism.io API key.
I created a directory called
and then another sub-directory under that called
You’ll next fetch the first challenge (in the
If you list the contents of the hello-world directory you’ll see:
It’s tempting to jump right in and start writing the implementation in
. Let’s set a good habit right now: run the tests first!
The README.md contains interesting information about how to run the tests. Assuming I’m using Python 2.7, then I would run:
You just ran the tests (pre-written by the challenge author) but since there is no implementation the tests failed. Our next step is to provide that implementation.
Every time we make an update we should run the tests, as above. We’ll know very quickly if we made progress or introduced a bug (a regression).
Here’s an example implementation you can use in
def hello(name=''): return 'Hello, World!'
Let’s rerun the tests and see how we did:
And that’s that. Let’s push our solution back to Exercism.io:
Your python solution for hello-world has been submitted.
Programmers generally spend far more time reading code than writing it.
To benefit the most from this exercise, find 3 or more submissions that you can
learn something from, have questions about, or have suggestions for.
Post your thoughts and questions in the comments, and start a discussion.
Consider revising your solution to incorporate what you learn.
Yours and others’ solutions to this problem:
I bet you’ll be ready to devour the next one. Good luck!
If you want a more detailed example of writing tests, check out Keep Calm and Add Unit Tests with Python.