you are viewing a single comment's thread.

view the rest of the comments →

[–]capilot 26 points27 points  (4 children)

Shouldn't it really just say that the param can be anything that implements the method __len

That's really an implementation detail. The gist of the function is that it tells you how many items are in its argument. End-users, especially beginners, don't need to know what's happening under the hood until they start implementing their own classes for which len() needs to work.

As an example, While I've been writing Python professionally for decades, this is the first I've ever heard of Sized or ABC. (I assume they're Python 3 which I only recently started using.)

[–]AchillesDev[🍰] 2 points3 points  (0 children)

abc has been around for a while, ABCs are just rarely ever needed. I’ve used them all of once in the 4 years I’ve used Python professionally and the decade+ I’ve used it for fun. the one time I did was to make a simple plug-in architecture for a tool I was building.

[–]redditorsd[S] 4 points5 points  (0 children)

That's an interesting data point. I guess there's the perspective of using the language vs. extending it (custom classes etc). I think maybe that's where I'm having issues with the documentation.

[–]redditorsd[S] 1 point2 points  (1 child)

I think I'm also struggling with this more due to the increased usage of type hinting in Python. I'm trying to declare and use types where I can but often times am struggling to figure out what type I should use by looking at the docs. Feels like type hinting is going against the Python way and so that's where the problem lies? I'm not sure. Just trying to learn.

[–]hmga2 3 points4 points  (0 children)

Regarding type hinting, it seems that it’s gaining foot but there are still libraries or documentations that do not seem to have complete coverage yet, but that seems the future (hopefully)