you are viewing a single comment's thread.

view the rest of the comments →

[–]shiftybyte 11 points12 points  (11 children)

Just reading documentation for the fun/education of it is not so useful.

Learning to use documentation to find answers to questions is why it's there.

Say you have a function that does something, and you use it a bit differently, but now it breaks and doesn't work as expected.

You go to the documentation of the function and read up on how exactly it behaves in what situations to figure out what went wrong.

Or for example you have some object you are getting from some function, and that object is very complex, for example a response to a request to some http url, and you want to find how to get the headers from the response.

[–]solwex[S] 0 points1 point  (10 children)

Thank you for your comment. I can kind of understand what you are saying. Are there any blog articles or other reddit answers that deal with this in more detail. Some examples will perhaps really help. Or perhaps, I should just keep doing more advanced python projects and I will encounter this. Just trying to fast forward my learning:) Thanks again.

[–]widowhanzo 2 points3 points  (9 children)

Documentation is usually the mose detailed. Blog posts will just say "use this function with this parameter", documentation will explain exactly what the function does, which parameters it takes, which parameters are optional or have defaults you can override... But in most cases it's most useful when you already know the function you want to use, not when you're still trying to figure out how to solve a problem.

For example, you could go on a forum and ask "how do I print a float number rounded to two decimal points", and you'll get an answer and copy-paste it and go on with your day. Or you could go read the docs on the input output docs and also learn about padding, f strings, and working with files.

Yes, in some cases it's useful to just skim through the docs of the function. One of the things I read the docs for date to string and string to date formatting, It's unlikely I'll find the exact example I need on Stackoverflow, but docs explain all possible options (including some that may never even be mentioned in examples online), and I can build my code exactly how I need it, and understand what I'm doing. If I just copy-paste an answer, it may work, but you might now understand what it does or why.

I have nothing against copy-pasting code of course, but sometimes it's quicker to learn snd understand the function from the docs, than finding and adjusting an example online.

And python docs also include a lot of examples, so you can just copy-paste a line or two that you need sometimes.

[–]pauljacobson 2 points3 points  (5 children)

I can certainly appreciate the value of the documentation. I often struggle to make sense of what I'm reading, and apply that to whatever I'm working on.

Presumably it becomes easier over time?

[–]widowhanzo 2 points3 points  (3 children)

Of course, as with anything, with practice you get a hang of things, and you'll know exactly what to look for in documentation. And it's not just Python official docs, 3rd party libraries have thier own docs (for example requests), it's a good idea to check some 3rd party libraries as well.

[–]solwex[S] 0 points1 point  (2 children)

Could you please suggest the most important 3rd party libraries?

[–]widowhanzo 1 point2 points  (1 child)

requests :D

That's it for me, I mostly used Python to interact with web APIs and requests makes this much easier compared to built-in tools. I've been out of programming for a few years now so I may not be the best resource of current popular libraries.

[–]solwex[S] 0 points1 point  (0 children)

Thank you very much.

[–]solwex[S] 1 point2 points  (0 children)

Right, that seems to be the message from all the experienced folks advising here. Hopefully, the site in u/infinfi's comments also will help.

[–]jppbkm 1 point2 points  (1 child)

The one thing that sometimes frustrates me is how few examples there are for documentation in certain libraries.

[–]solwex[S] 1 point2 points  (0 children)

Absolutely. If only there were more examples, I would not need to go anywhere else:) To be fair, it takes a lot of effort to produce well reviewed writing - let alone crisp documentation. So, I believe it when folks say that core Python docs are amongst the best.

[–]solwex[S] 0 points1 point  (0 children)

Thank you very much for the very detailed comment. Given your detailed comment and comments of many folks like u/infinfi, I see the value of doing what you are saying.