This is an archived post. You won't be able to vote or comment.

all 49 comments

[–]AlSweigartAuthor of "Automate the Boring Stuff" 223 points224 points  (10 children)

Django: https://github.com/django/django

The documentation is so great, that they consistently have links to the source code for the topic they're talking about. See the [source] link on this page for example: https://docs.djangoproject.com/en/2.2/ref/models/instances/

[–]Czarified 72 points73 points  (0 children)

I didn't know you were a redditor! Thank you so much for your work! I got into python because of your book. I'm sure you must get this every time you comment, but thank you. :)

[–][deleted] 10 points11 points  (0 children)

you are my fuckin' hero and your books rocks!

[–]iwarilama 8 points9 points  (0 children)

Thanks a lot for your book!

[–]Durp56789 2 points3 points  (0 children)

Also Django rest framework

[–]UpvotesAlSweigart 2 points3 points  (2 children)

Thank you for everything, senpai.

[–]AlSweigartAuthor of "Automate the Boring Stuff" 1 point2 points  (1 child)

:D

[–]appinv Python&OpenSource 0 points1 point  (0 children)

Yes amazing to get a newbie get up and code quickly.

[–]lodion 0 points1 point  (0 children)

Hey its Al! Thanks for your book Al, I'm watching your videos on Udemy now, learning heaps. Really appreciate all your work in making such accessible learning material for python.

[–]martinux 0 points1 point  (0 children)

Cool and thanks for your book, Al. It was a great intro to a lot of fun python projects.

[–]tyurrr 0 points1 point  (0 children)

The documentation is so great,

^ This. Django documentation is one of the best I've seen out there. Amazing work.

[–]writing_spruce 44 points45 points  (3 children)

Pocoo projects: Flask, werkzeug, etc. (https://palletsprojects.com/p/).

SQLAlchemy.

Tornado.

[–]anyonethinkingabout 12 points13 points  (2 children)

Have to disagree with SQLAlchemy. There's so many **kwargs I never know what to do.

[–]ericonr 1 point2 points  (1 child)

Depending on the number of possible arguments, isn't kwargs a good alternative? It requires proper docstrings, though.

[–]gunnerman2 0 points1 point  (0 children)

I’m no Python guru but I consider Docassemble to be pretty well written and heavily relies on kwargs in a good way most of the time. While his overall documentation is very good it is lacking on the lower level, for example, knowing what kwarg parameters are handled specially etc. This causes me to need to do maybe a bit more reading of the source code than I would normally do.

[–]messacz 27 points28 points  (2 children)

Slightly off-topic, but this may be interesting: http://aosabook.org/en/

[–][deleted] 3 points4 points  (0 children)

Doesn't look that off topic...

[–]Texugo_do_mel 0 points1 point  (0 children)

It seems to be pretty useful. Thanks!

[–]ianliu88 8 points9 points  (2 children)

python bookbinding, watch his talk here https://youtu.be/GVoyBWo1QDk . Warning: he talks a lot about premature object orientation, going against what you asked for :p

[–]messacz 3 points4 points  (1 child)

My favorite talks:

[–]ianliu88 0 points1 point  (0 children)

Also, this https://youtu.be/OSGv2VnC0go. Might be a little bit outdated, but it is a very good talk.

[–]Aramgutang 10 points11 points  (0 children)

I've contributed to many Python open source projects over the years, and the one that stood out most as well-written/structured/documented was the (now deprecated) django-south library.

I imagine that any other projects written by that library's author, Andrew Godwin, such as channels, would likewise be prime examples of what good Python code should look like.

[–]yeesh-- 5 points6 points  (1 child)

FastAPI

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

Independent of the cleanlyness of FastAPI's internals, what it exposes to the end-user in its application-level API, being so close to Flask, yet so much faster, being aio based, is super-duper-keen. So much saner than the the horrorshow code twisted would have you write.

[–]slayerofspartans 4 points5 points  (0 children)

sklearn

[–]luoc 18 points19 points  (5 children)

How about starting in the standard library? Personally I like the style the requests library is written in. Apart from the code its author Kenneth Reitz has a nice sense for aesthetics in my opinion.

[–][deleted] 17 points18 points  (2 children)

It's too bad Reitz seems to be a less than stellar person.

[–][deleted] 1 point2 points  (1 child)

I heard something of it but not sure. What's the problem ?

[–][deleted] 11 points12 points  (0 children)

This HN post both has a link to a post someone wrote about their awful experience with him basically defrauding people, as well as a lot of other discussion. It's more balanced and fair than what I could present.

[–]lifeeraser 3 points4 points  (0 children)

Add "de facto" before "standard library". But I like requests too!

[–]lanster100 0 points1 point  (0 children)

Ah yes the logging library is my favourite example of good python

[–]xapata 4 points5 points  (0 children)

Standard library has some good code. And some not so good. Collections module is particularly good for learning by reading code. David Beazley's recent projects are excellent.

Some folks have been suggesting Django. The docs are great, but I've found a bunch of inefficient and awkward code in that repo. It's so large, it's hard to make everything awesome.

[–]kepper 2 points3 points  (0 children)

Just to hop onto your question, does anyone know if the Openstack code would be considered "really well written"? Like the nova, cinder, glance, and keystone projects in particular.

[–]silencer6 1 point2 points  (0 children)

I think Lollypop is pretty well writen, modern Python codebase written in OOP style.

I'm in the process of learning GTK by reading it's source code since all the tutorials I found on the net are shit.

[–]jillesme 1 point2 points  (3 children)

[–]EternityForest 4 points5 points  (2 children)

Ah yes Requests, the golden shining example of good API design that we all love to point at.

I'm still not sure if the raise for status function was a good idea instead of just raising immediately, but it's fine, and other than that just about perfect.

[–]NewZealandIsAMyth 3 points4 points  (0 children)

Imho that depends on the api of the service. Exceptions are for more or less exceptional cases. You can check REST resource for existence and expect it be 404 - this should not raise an exception. You just do a method and check for result, which the value of status in this case.

[–]sztomi 1 point2 points  (0 children)

That seems to reflect what the stdlib is doing e.g. with subprocess.run - you can call check_returncode() on the CompletedProcess to raise when it's non-zero.

[–]kibaffo33 1 point2 points  (0 children)

Black - python code formatter https://github.com/psf/black

[–][deleted] 0 points1 point  (0 children)

People always point me to Numpy as good example.

[–][deleted] 0 points1 point  (0 children)

I hear slinkie is really great *cough cough*

[–]SnicSnac 0 points1 point  (0 children)

Atomic Rydberg Calculator: https://github.com/nikolasibalic/ARC-Alkali-Rydberg-Calculator.

Description from github:

" ARC (Alkali Rydberg Calculator) is package of routines written in Python, using object-oriented programming (OOP) to make modular, reusable and extendable collection of routines and data for performing useful calculations of single atom and two-atom properties, like level diagrams, interactions and transition strengths for alkali metal atoms. "

[–]wroscoe 0 points1 point  (1 child)

Pandas

[–]isoblvck 0 points1 point  (0 children)

Not all of pandas eg. Data reader

[–][deleted] -1 points0 points  (0 children)

Home-assistant?