How to learn Python?
I have been asked this question on a few occasions. People of various backgrounds are looking to find their way to becoming a Pythonista. As of November 2021, Python is the most popular programming language according to the TIOBE index. Learning Python is a wise choice but where to start and how to master it?
In 2020 I was invited to join in the Python courses at Software University as a lecturer. For the next few months I taught programming in Python to a group of ~250 people as part of the Fundamentals, OOP and Advanced modules. The experience of teaching people programming in Python was highly beneficial for me. Previously I tried to teach other individuals with a variable success rate. Working with many Python students simultaneously taught me that slow and steady wins the race. As a teacher I also learned to rush less. Sometimes talanted students fall into the trap of impatient teachers.
Theory and Practice
Theory is when you know everything but nothing works. Practice is when everything works but no one knows why. In our lab, theory and practice are combined: nothing works and no one knows why.
– Unknown
Mastering a new skill requires both theoretical and practical knowledge. Solely reading the road traffic law, studying the car manual book and watching thousands of YouTube videos with driving tips & tricks is insufficient to becoming a driver. Doing these might give you a theoretical basis that needs to be combined with a practical one. At some point you need to get behind the wheel and drive.
Same goes with Python. There are excellent sources of theoretical knowledge. The Python documentation is excellent. There are thousands of videos on YouTube teaching Python. Plenty of courses on the internet are covering web development, QA automation and machine learning with Python. At some point you need to get behind the keyboard.
How to gain the theoretical knowledge?
You can start in any order as you preffer. You may even skip some of the suggestions that I make. As a self-taught Python developer I encourage you to take any path that makes sense to you.
- Read the Python documentation, or at least skim through it to know what it offers. Check what the official website offers you.
- Take a course or two online, Udemy, Coursera and Udacity are great places to start. Every lecturer will offer some unique suggestions, so choose what you like.
- Order a book and read it. You may check some of the already popular publishers, like O’Reilly, Manning or Packt. It doesn’t matter what you’ll read. Trust your gut and you will make the right choice. Make sure to pay for the book. Things we pay for are more valuable. Read it slowly and try the code samples.
- Watch YouTube videos. Search for “Learn Python” and watch the videos. There is plenty of material out there.
- Google it. Anytime you’re puzzled - do the Google search. “How to sort a list of integers in Python?”, “How to start a Django project?” or “How to create a Python virtual environment?” - Google won’t judge you for asking those questions over and over again.
Where to practice Python?
You will need to train your brain, eyes and hands coding in Python. An excellent way to get used to the language is to solve challenges at HackerRank. After a few weeks of solving challenges you might want try something more practical.
A good way to practice would be to follow some of the guides online and explore the broader Python ecosystem. You may write a Django application, implement a scraper with Scrapy or check lists with app ideas on GitHub and start a custom project.
Persistence is key. The process of learning is slow. Seemingly “simple” tasks will take a lot of time to understand and complete. You will be developing a broad knowledge base not only related to Python, but also touching databases, HTTP, Git and plenty of other areas. At this point you may start feeling lost or even frustrated, and it’s important to keep going. Having a practical project to work on is essential. The small wins achieved on a daily basis will assure the rush of dopamine in your blood and will keep you going.
The social aspect of learning
There is a social component in the learning process. People learn from each other and build on top of each other’s understanding. The whole is more than the sum of its parts. Studying within a community of other people with similar interests enables a new dimension of dynamicness.
You may consider attending a training centre or academy where they teach Python in a face-to-face form. If you prefer studying online, there’s plenty of opportunities to collaborate with other students as well. Sticking with the group will make the learning process more durable.
Explore the ecosystem
The Python programming language is great, but it’s ecosystem is better. You will barely do anything just in Python. Any real life Python project uses 3rd party dependencies. Spend some time to explore the Python Package Index (PyPI). Check the Python topic at GitHub. Take a look at the exciting projects other people are doing in Python.
Check the standard library
The Python approach is to come with plenty of batteries included - it has a rich and versatile standard library. By simply installing Python you will be able to do file compression, work with various file formats, handle emails, call resources on the internet and plenty of other things. Check the documentation and learn what Python offers.
Concluding thoughts
Python is just a tool in a toolbox. Yes, this tool is like a Swiss Army knife. But learning just a single tool won’t be sufficient. Depending on the domain you want to work in, you will need to learn about backend development, object oriented programming, functional programming, databases, operating systems and what not.
Yes, the advices given in this article are valid for any other programming language. Everyone has different learning habits. I hope you find this post useful. Now go ahead and start learning.