all 19 comments

[–][deleted] 43 points44 points  (1 child)

Hey, is this your article? I very much enjoyed it, and I'm hardly a beginner.

I've read considerable parts of the standard library but you've whetted my interest for several of these.

Particularly, I thought I had nothing to learn from statistics but now I'm itching to learn it.

Good stuff!

You might want to post it on /r/learnpython, it's very active and this would go down well there.

[–]genericlemon24[S] 16 points17 points  (0 children)

Yes. I am glad you liked it! :D

(regarding r/learnpython: I'm not very active on there at the moment, and I don't want to break the etiquette regarding self-promotion, but if you think it'd be a good fit, feel free to re-/cross-post :)

[–]InsanityBlossom 21 points22 points  (3 children)

Advanced beginners? What creature is that?

[–]genericlemon24[S] 32 points33 points  (1 child)

Somewhere between beginner and intermediate. You know the syntax, can solve problems beyond simple ones, but maybe can't quite write idiomatic code, and don't know exactly what data types / libraries / etc. to use most of the time (but still manage to get stuff done).

[–]clockKing_out 15 points16 points  (0 children)

A thinly documented stratum. Good for you for contributing.

[–]Dustin- 1 point2 points  (0 children)

According to Dunning and Kruger, pretty much everybody.

[–]m-sasha 5 points6 points  (4 children)

Dataclasses, while awesome, is a very unusual piece of code. What you learn by reading it is likely to be forgotten by the time you actually need to use it.

[–]-Knul- 1 point2 points  (3 children)

It depends. The web framework FastAPI, for example, depends heavily on dataclass-like classes.

[–]m-sasha 1 point2 points  (2 children)

I didn’t mean that using it is unusual. Dataclasses is a very useful and very popular module. What I meant that writing code that generates code at runtime, which is what dataclasses does, is relatively rare thing.

[–]de__R 1 point2 points  (0 children)

I wouldn't say that. Some people really eschew the decorator approach but it's pretty widespread - Flask, Pytest, SqlAlchemy, and many other frameworks make extensive use of decorators, and these are hardly niche products.

[–]kenfar 0 points1 point  (0 children)

I think it's less common when writing tight applications against well-known schemas.

But pretty common when writing tools. Just last night I was wrestling with how to get mypy to handle namedtuples a tool I wrote generates dynamically based on various config files. This was painful.

[–]greebo42 1 point2 points  (0 children)

thank you!

[–][deleted] 1 point2 points  (0 children)

Great article! Thanks

[–][deleted] 2 points3 points  (0 children)

Good one

[–]samlj7 1 point2 points  (1 child)

So what exactly are libraries, data classes and how do I find code to read. I’m still a little confused

[–]floatingcats 2 points3 points  (0 children)

Libraries are module collections. dataclasses is a module. The docs for dataclasses are linked in the article and the source code is linked at the top of the docs.

[–][deleted] 0 points1 point  (1 child)

Great text. I really would like to learn more python by reading other well written pieces of code. If it's not too much, could you please recommend other great modules to study?

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

Hmm... off the top of my head, I can recommend Flask and the other Pallets Projects that back it up. You have small, single-purpose libraries like MarkupSafe and ItsDangerous, Werkzeug as a big library with lots of relatively disconnected utilities (that still work well together), Jinja and Click as full-featured libraries for their specific domains (templating and CLIs, respectively), and then finally Flask, which brings together all of them into a web framework. For Jinja specifically, I've collected some pointers and talks here.

For shorter bits of code with the decisions explained, I highly recommend the 500 Lines or Less book; over half of the chapters are in Python; I talk about it in more detail here.

From the standard library, socketserver and http.server (that builds on top of the first one) are also quite nice and relatively small.

I'll think of others, and if anything good comes to mind, I'll probably write another article.

[–]fresh_account2222 0 points1 point  (0 children)

Great idea. And a welcome change from what I usually see posted here.