I am at a high-beginner/low-intermediate level in Python, and one thing that drives me nuts is how poorly I am able to read the Python official documentation and grok how to use the described code.
What’s the secret? Are there any guides/videos/books that can help my understand how to approach reading it? Or, is it just one of those things that I need to just keep coming back to while coding, and eventually I will get the hang of it?
Python docs are mostly “reference” material. Which means it’s not intended to show you how things are done, but used as detailed descriptions of commands/statements/classes/methods.
This is why you are having trouble understanding it. You first need to go understand fundamentals of it and they will be useful when you need details and intricacies of something while using it.
Honestly I still often look up alternate documentation, searching “how do I do x?” instead of reading the actual documentation. I think the official documentation tends to be very technical about everything you need to know about the modules, etc. But if you’re trying to get one particular thing done in a hurry, finding something someone else has already done and copying it as much easier.
That said, I do believe the official documentation gets better with age/the more you come back to it.
If you are looking for books, check out:
Intermediate:
- Beyond the Basic Stuff with Python — Best Practices, Tools, and Techniques, OOP, Practice Projects
- Pydon’ts — Write elegant Python code, make the best use of the core Python features
- 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
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
- Intuitive Python — productive development for projects that last
The docs are pretty great… once you’re deep into it and understand the stuff it glazes over. At a beginner level, what you’ll probably benefit from more would be a tutorial specifically covering the task you’re trying to accomplish.
Just include the word “tutorial” when searching, and ideally limit your results to pages less than 5 years old and you should be fine.
I feel the same and I’ve been using Python for years professionally. It’s the lack of examples for me; usually functions and classes aren’t meant to be used as-is but rather fed as an argument into some other function or class, and this info is seldom portrayed in the func’s documentation. E.g. the documentation of
BaseHTTPRequestHandler
is one that I trip over every single time, I have to resort to reading the source code ofSimpleHTTPRequestHandler
to remember how handlers are supposed to be defined 🐺Well put. I also hate that it always dives into edge cases but never explains the basics.
Read a good book instead. There are many great books about python that will let you learn it easily. I don’t think learning it from the docs only is a great idea.