this post was submitted on 27 Aug 2023
56 points (98.3% liked)

Python

6347 readers
3 users here now

Welcome to the Python community on the programming.dev Lemmy instance!

πŸ“… Events

PastNovember 2023

October 2023

July 2023

August 2023

September 2023

🐍 Python project:
πŸ’“ Python Community:
✨ Python Ecosystem:
🌌 Fediverse
Communities
Projects
Feeds

founded 1 year ago
MODERATORS
 

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?

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 8 points 1 year ago (2 children)

What exactly is the issue? I think some modules are better than others. But, if the method says what its arguments are, what their types are, and what the return is, what's the issue?

Some things are more complex, and the docs I've used generally seem to be good about including examples. Like MagicMock. But, maybe if you gave an example of something you found hard to understand we could help?

[–] [email protected] 5 points 1 year ago

I've always found the python docs to be very complete.

[–] [email protected] 2 points 1 year ago* (last edited 1 year ago) (1 children)

I've been generally happy with the documentation, but sometimes you need to see how something is supposed to be used.

It's not the python documentation, but the Qt documentation (which is used to understand PyQt) where I wanted to play some video. Well, you need a QMediaPlayer to control the video. But the video apparently needs to be a QGraphicsVideoItem for the actual video, but wait that also has to be in something, Turns out you need to put it into a QGraphicsScene, which ALSO needs to be in a QGraphicsView. And it wasn't easy to find out, because some of these needed to take another item as init argument, while others needed to call a method to add them. So you are left to figure out what all these things are and what purpose each of them do differently, which order all should be created in, and try too keep track without messing up all the similar type names. One place where loosely typed python gets real weak. It's seemingly obvious from the way I wrote it though, but having just the video playback as my starting point, finding out what classes to use to begin with was hard.

Another case isn't Python, but C#. Where some framework docs give class definitions but don't tell you that those are used to be "subclassed" to override a specific method and then the class is set as a property on a object you want behavior to change for, using a class name that really wasn't letting on what it was doing at all. This happened after ChatGPT came into existence, and it throw me a complete example. Other times tho, it makes up a similar thing.... which sucks

[–] [email protected] 1 points 1 year ago (1 children)

Well that's totally different. Last time I looked at pyqt, those docs were a nightmare. I would always go to the c++ docs.

Same with any other random docs. They absolutely vary in quality and usefulness. But you were talking about the official python docs, no?

[–] [email protected] 1 points 1 year ago

My point was just, just input and output often isn't enough to tell you how to use something. Qt is an extreme example, but even the C++ docs leave how to use more complex objects out. Which makes em a pain to learn to use. I see some similar examples mentioned for the python docs here as well.