My advice on learning Python: Don't set out to "learn Python". Choose a problem you're interested in and learn to solve it with Python. - Jake VanderPlas
Python is a mature language, easy to learn and here to stay. But where to start?
We see a lot of new Pythonistas posting questions like: How do I learn Python?, Where do I start?, What approach should I take?
We were there once too. Now with 9 months of PyBites and 200 articles under our belt, we share how we learned Python.
Special thanks to Derek Siver’s How to learn JS which planted the seed for this Post #200 Special.
Creating PyBites has been an amazing experience and has resulted in me learning more Python than I could have imagined.
My Python journey started a lot later than Bob’s, thus the large experience gap between the two of us. Over the past year however, my skills have improved significantly. These are the resources and methodologies I used to try and close the gap:
Learn by Doing
Learn by Doing. I needed a better way to track the amount of money I was earning while working overtime to make sure I was being paid correctly by my ex-employer.
Finding something to make for yourself is by far the most effective way to learn Python. As Jake VanderPlas tweeted there is no better way to learn the language than to find a problem you like to solve. Also: "necessity is the mother of invention". This simple concept will ensure you remain motivated to see the project through to completion.
Automate the Boring Stuff (ATBS) by Al Sweigart. This is the book that got me off the ground. It’s a wonderful starting point to get you solving your first coding problem. I kept this book open the entire time I coded my Overtime Tracker app. Some techniques may be a little dated now (camelCase) but the foundations ring true and are still applicable.
Fluent Python and Head First Python: ATBS is a great starting point but that’s about it. To get to the meatier and more complex parts of Python I started reading through both FP and HFP. I didn’t read them cover to cover. Rather, I read through what interested me at the time. They are resources, not novels. Skip to what you need. It keeps it interesting and stops it getting boring. THEORY is covered in other books. These books are amazing references so I still keep them handy.
100 Days of Code
Take this challenge. It doesn’t matter how far along you are, just do it and log it. It’ll be tough and it’ll be frustrating so try and plan to do it in a “quieter” quarter of the year. If no quarter is quiet then suck it up and just do it.
Make yourself accountable.
Coding for 100 days straight is an incredibly satisfying experience. We did it. We loved it and we hated it. The outcome however, was the same for both of us. We learned an absolute shitload over the 100 days and we’re better off for it!
Explore Other People's Code
Browse PyPI: This admittedly came about thanks to the 100 days of code challenge. I needed ideas. Head to PyPI and just browse. Expand the categories, look through the packages and soak in the incredible problems people are solving with Python! Do this seriously and you will find inspiration. Same for open source projects on GitHub.
I’ve found wonderful packages that have helped me solve problems both professionally and personally. Immerse yourself in a package that interests you and use it to make something cool. An example of the random awesomeness: I found a package to interface with my TV!
Learn a Web Framework
The Flask Mega-Tutorial by Miguel Grinberg: I wanted nothing more than to turn my CLI based scripts into beautiful web apps. This Flask tutorial was my enabler. I’m now an unashamed Flask addict and have created web interfaces for even the most mundane processes.
I can say without a shred of doubt that learning Flask pushed me harder than anything else before it. It was tough but it was and continues to be oh so satisfying!
If you are going the web development route you might also want to checkout freeCodeCamp.
Write a Blog and use GitHub: There’s nothing quite like teaching, writing or sharing to cement coding concepts. Having to formulate your learning into meaningful and comprehensible explanations is a wonderful way to learn! This applies to anything, not just Python!
Seeing what you accomplish in the form of a blog, site or repo is soothing for the soul.
It’s held me accountable and kept me motivated. Similarly sharing my code on GitHub encourages me not to cut corners and to keep my code as clean as possible (you never know who’s watching right?!).
Code Challenges: not as shameless a plug as it seems (maybe a little ...): Challenge yourself!
I was horrified when we eventually created a challenge around APIs. I didn’t even know what API meant! The challenge pushed me to learn and create something new.
Code challenges are there to get you out of your comfort zone and doing things you’ve never considered.
It didn’t matter how simple or complex the end product was, all that mattered was that I’d challenged myself with a new concept and had fun along the way. These are definitely an understated learning tool.
Starting PyBites and actively organizing and solving code challenges have made a major contribution to my Python learning.
I am squarely behind Julian's recommendations! Here are some key things I learned during my Python journey:
Build Stuff and Share it
Before PyBites I already had my own blog with a build-to-learn approach. The practice is what counts.
As Julian mentioned #100DaysOfCode pushed us and we learned a lot. We kept the habit by doing new 100 Days Projects since.
If you code something every day or week and share it with the community I would be surprised if opportunity is not coming your way over time.
PR it or it didn't happen somebody said at work. Spot on! You can code in your cave but unless you share it, the world won't notice, can't try it and feedback, hence no opportunity to grow.
Automate Stuff at Work
I was fortunate to grasp a big opportunity at work that changed my career. I built a tool to automatically parse log files of X86 servers. It saved the support staff 1000's of hours.
In this digital age where software is eating the world (Andreessen Horowitz), there are opportunities everywhere to hone your coding skills.
I started the work in PHP and shell scripting then moved to Perl, got in a maintenance mess, then luckily discovered Python. I never looked back. I am happy it went this way: I even more appreciate Python's elegance and conciseness now. Seeing a Python solution having an impact on business is very rewarding.
It also led to my next big assignment: automate diagnostics of x86 hardware support calls, a framework I got to build in vanilla Python. You can read the full story here.
Sharpen the Saw
Although this gave me plenty of practice, it was not till the following phase that I really got better at Python:
Start a community effort. PyBites is not only a blog to learn and teach Python, via our challenges, social media and conferences, we actively engage with the wider community. Python happens to have an awesome community, leverage it!
In Special Post #100 we described how our blog came about. It created greater depth, understanding and context for us. The exciting (and sometimes overwhelming) part is that there is always more to learn.
In that regard keep practicing and studying:
Practice: the code challenges enforce us to keep producing code + solutions. Although a serious time investment the reward is huge: better skill development, building up a portfolio, community collaborations, and utilities we can use. This is the most rewarding and fun part for us and even more so when other developers submit their solutions for inclusion in our review post.
Study: this sounds obvious but books and tutorial consumption can get on the back burner easily. It's paramount though: Fluent Python, Python cookbook, Mike Kennedy's courses, Real Python, Dan Bader, these resources taught me more and better Python. Set some time aside each week to consume these and other great resources.
Work as a developer / for a dev team: being self-taught this obviously did not happen day 1, but you can certainly grow into it. Specially when accumulating your personal portfolio and network.
I cannot recommend this goal highly enough. Work with more experienced software developers. Look at people that are further in their programming careers. What did they do to get there? No better exposure to be part of a dev team, go through code reviews and design discussions.
You will be amazed how much you will learn joining a dev team. How much it can stretch you. Remember: growth happens outside your comfort zone.
Write Guest Posts. Related to previous point: higher standards. Writing for quality blogs you are held to their standards. I learned a lot writing posts for Pybonacci, Dan Bader, Twilio and Real Python.
To become a good Python developer understanding and following the Zen of Python you already adopt a lot of good practices.
Yet, some wider orientation pays off so I recommend reading books like Clean Code, Code Complete, Building Maintainable Software, Refactoring. And books on OOP, testing, design patterns and software architecture. A lot of the core principles are language agnostic so it does not matter these books teach in another language than Python.
We hope this article gave you some pointers and inspiration to get started with or delve deeper into your Python journey.
If you have additional tips or advice or want to share your Python story, use the comments below.
You can also email us if you have any suggestions or feedback.
Thanks for reading.
Keep Calm and Code in Python!
See an error in this post? Please submit a pull request on Github.