Python what next

Poster created using Canva


Next step🔗

Programmers often wonder what to do after learning the basics. Searching for what next on /r/learnpython will give you too many results. And here are some wonderful articles related to this topic:

I do not have a simple answer to this question. However, I'll list a few topics along with resources that might help you take the next step in your Python learning journey.


Exercises and Projects🔗

If you feel comfortable with programming basics and Python syntax, then exercises are a good way to test your knowledge. The resource you used to learn Python will typically have some sort of exercises, so those would be ideal as a first choice. I'd also suggest using the below resources to improve your skills. If you get stuck, reread the material related to those topics, search online, ask for clarifications, etc — in short, make an effort to solve it. It is okay to skip some troublesome problems (and come back to it later if you have the time), but you should be able to solve most of the beginner problems. Maintaining notes and cheatsheets will help too, especially for common mistakes.

info See also this article on solving programming exercises.

Once you are comfortable with basics and syntax, the next step is projects. I wrote a 10-line program that solved a common problem for me — adding body { text-align: justify } to epub files that are not justify aligned. I didn't know that this line would help beforehand. Found a solution online and then automated the process of unzipping epub, adding the line and then packing it again. That will likely need you to lookup documentation and go through some stackoverflow Q&A as well. And once you have written the solution and use it regularly, you'll likely encounter corner cases and features to be added. I feel this is a great way to learn and understand programming.

These days, I use a better EPUB reader that allows me to customize alignments. Here's another real world example. I'm on Linux and use the terminal for many things. I wanted a CLI tool to do simple calculations. There's bc command, but it doesn't accept direct string argument and you need to set scale and so on. So, I looked up how to write a CLI tool in Python and wrote one using the built-in argparse module that works for my particular use cases.

Here are some resources to help you get started on projects:

info See also The Good Research Code Handbook to learn how to organize your code so that it is easy to understand and works reliably.


Debugging🔗

Knowing how to debug your programs is crucial and should be ideally taught right from the beginning instead of a chapter at the end of the book. Think Python is an awesome example for such a resource material.

Sites like Pythontutor allow you to visually debug a program — you can execute a program step by step and see the current value of variables. Similar feature is typically provided by IDEs like Pycharm and Thonny. Under the hood, these visualizations are using the pdb module. See also Python debugging with pdb.

Debugging is often a frustrating experience. Taking a break helps (and sometimes I find the solution or spot a problem in my dreams). Try to reduce the code as much as possible so that you are left with minimal code necessary to reproduce the issue. Talking about the problem to a friend/colleague/inanimate-objects/etc can help too — known as Rubber duck debugging. I have often found the issue while formulating a question to be asked on forums like stackoverflow/reddit because writing down your problem is another way to bring clarity than just having a vague idea in your mind. Here's some more articles on this challenging topic:

Here's an interesting snippet (paraphrased) from a collection of interesting bug stories.

A jpeg parser choked whenever the CEO came into the room, because he always had a shirt with a square pattern on it, which triggered some special case of contrast and block boundary algorithms.

info See also this curated list of absurd software bug stories.


Testing🔗

Another crucial aspect in the programming journey is knowing how to write tests. In bigger projects, usually there are separate engineers (often in much larger number than code developers) to test the code. Even in those cases, writing a few sanity test cases yourself can help you develop faster knowing that the changes aren't breaking basic functionality.

There's no single consensus on test methodologies. There is Unit testing, Integration testing, Test-driven development and so on. Often, a combination of these is used. These days, machine learning is also being considered to reduce the testing time, see Testing Firefox more efficiently with machine learning for example.

When I start a project, I usually try to write the programs incrementally. Say I need to iterate over files from a directory. I will make sure that portion is working (usually with print statements), then add another feature — say file reading and test that and so on. This reduces the burden of testing a large program at once at the end. And depending upon the nature of the program, I'll add a few sanity tests at the end. For example, for my command_help project, I copy pasted a few test runs of the program with different options and arguments into a separate file and wrote a program to perform these tests programmatically whenever the source code is modified.

For non-trivial projects, you'll usually end up needing frameworks like built-in module unittest or third-party modules like pytest. Here's some learning resources.


Intermediate to Advanced Python resources🔗

Intermediate

  • Official Python docs — Python docs are a treasure trove of information
  • Pydon'ts — Write elegant Python code, make the best use of the core Python features
  • Calmcode — videos on testing, code style, args kwargs, data science, etc
  • Practical Python Programming — covers foundational aspects of Python programming with an emphasis on script writing, data manipulation, and program organization
  • Beyond the Basic Stuff with Python — Best Practices, Tools, and Techniques, OOP, Practice Projects
  • Python Distilled — this pragmatic guide provides a concise narrative related to fundamental programming topics such as data abstraction, control flow, program structure, functions, objects, and modules
  • Python in a Nutshell — use modern Python idiomatically, structure Python projects, how to debug

Algorithms and Design patterns

Advanced

  • Fluent Python — takes you through Python's core language features and libraries, and shows you how to make your code shorter, faster, and more readable at the same time
  • Serious Python — deployment, scalability, testing, and more
  • Practices of the Python Pro — learn to design professional-level, clean, easily maintainable software at scale, includes examples for software development best practices
  • Advanced Python Mastery — exercise-driven course on Advanced Python Programming that was battle-tested several hundred times on the corporate-training circuit for more than a decade

Handy cheatsheets🔗


More Python resources🔗

Inspired by this post, I made a Python learning resources repository which is categorized (beginner, intermediate, advanced, domains like web/ML/data science, etc) and includes a handy search feature.


I hope these resources will help you take that crucial next step and continue your Python journey. Happy learning :)