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?

  • fsniper@kbin.social
    link
    fedilink
    arrow-up
    6
    arrow-down
    1
    ·
    1 year ago

    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.

  • bucho@lemmy.one
    link
    fedilink
    English
    arrow-up
    4
    ·
    1 year ago

    I hate the official python documentation. I often find what I’m looking for much quicker just by asking ChatGPT. You can even ask it to pretend it’s William Shatner while explaining how to use a given function. So that’s fun.

  • hackeryarn@lemmy.world
    link
    fedilink
    arrow-up
    4
    ·
    1 year ago

    I feel like this is a trend with dynamic languages that have a REPL. I’ve done a lot of Common Lisp in the past, and had the same feeling.

    The best way to get over this is to pop open the python REPL and start playing around with the options and functions. It takes very little ceremony to get a nice example rolling.

    https://realpython.com/python-repl/ has some nice advice and tips on some extra things you can do.

  • maor@lemmy.org.il
    link
    fedilink
    arrow-up
    3
    ·
    edit-2
    1 year ago

    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 of SimpleHTTPRequestHandler to remember how handlers are supposed to be defined 🐺

  • ryokimball@infosec.pub
    link
    fedilink
    arrow-up
    3
    ·
    1 year ago

    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.

    • maor@lemmy.org.il
      link
      fedilink
      arrow-up
      1
      ·
      1 year ago

      Yep, it’s more of a reference. I like the argparse tutorial and would love to see more docs of this kind though

    • Bristlerock@kbin.social
      link
      fedilink
      arrow-up
      0
      ·
      1 year ago

      Agreed. The lack of varied examples in documentation is my common tripping point. When I hate myself, I use visit SarcasmStackOverflow to find examples, and then reference those against the module’s documentation.

      And it’s definitely become an easier process as I’ve read more documentation.

  • Daniel Quinn@lemmy.ca
    link
    fedilink
    arrow-up
    3
    ·
    1 year ago

    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.

  • learnbyexample@programming.dev
    link
    fedilink
    English
    arrow-up
    3
    ·
    1 year ago

    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
  • flatbield@beehaw.org
    link
    fedilink
    English
    arrow-up
    3
    ·
    1 year ago

    Pick and choose. I actually like most of the Python Doc. Learned Python originally from their tutorial. Then learned key parts of the library. So I like those two documents. The other docs though can be deep. The language reference for example. Never read that except parts.

    I also had a book about Tkinter and another about Win32 Python programming. So I learned from those too. My first app was a data acquisition too with a Tkinter GUI. So I think a few books are good but maybe people do not do that now.

    For me, learned Python in a day mostly from their tutorial and the standard library reference, then it took me the next 9 months to actually get good at it. Then then still learning stuff 25 years later. I did have an advantage. I had been programming for 20 years before I learned Python and had used half a dozen other languages.

  • Midnitte@kbin.social
    link
    fedilink
    arrow-up
    1
    ·
    1 year ago

    Just want to highlight that if you feel there are improvements that could be made to the documentation, you can contribute to the documentation to help improve it!

  • 1984@lemmy.today
    link
    fedilink
    arrow-up
    1
    arrow-down
    1
    ·
    1 year ago

    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.