Live data from Hacker News

Ask HN: Good Python codebases to read?

news.ycombinator.com

31–40 of 153 posts

Re: Ask HN: Good Python codebases to read?

#31
post #11

Earlier quoted context omitted.

I have been debating whether or not to read the standard library, pro - it's the standard library, if I learn it I may save myself innumerable hours from reinventing wheels, con - it may not be the best example of code (thinking about the 400 line function from vim to see if there is input from the keyboard. Justified in context, but would be a horrible way to learn some code) Bazaar I may look into, as I know it's a…

I have some experience with the Mercurial code base, which I thought was pretty well engineered. It's not PEP 8, though, so that makes it slightly idiosyncratic. Might make an interesting comparison with Bazaar, though!

I haven't used Mercurial yet, let alone glance at the code base, but it might be worth a look ;-)

But honestly, the Bazaar code base is great. Great documentation at every level, and, as far as I can judge, some pretty good code too.

Re: Ask HN: Good Python codebases to read?

#32
post #31

Earlier quoted context omitted.

I have some experience with the Mercurial code base, which I thought was pretty well engineered. It's not PEP 8, though, so that makes it slightly idiosyncratic. Might make an interesting comparison with Bazaar, though!

I haven't used Mercurial yet, let alone glance at the code base, but it might be worth a look ;-) But honestly, the Bazaar code base is great. Great documentation at every level, and, as far as I can judge, some pretty good code too.

Thanks for that input, that is exactly what I am looking for.

Cheers!

Re: Ask HN: Good Python codebases to read?

#33
post #31

Earlier quoted context omitted.

I have some experience with the Mercurial code base, which I thought was pretty well engineered. It's not PEP 8, though, so that makes it slightly idiosyncratic. Might make an interesting comparison with Bazaar, though!

I haven't used Mercurial yet, let alone glance at the code base, but it might be worth a look ;-) But honestly, the Bazaar code base is great. Great documentation at every level, and, as far as I can judge, some pretty good code too.

Thanks for that input, that is exactly what I am looking for.

Cheers!

Re: Ask HN: Good Python codebases to read?

#34
post #25
post #18

Earlier quoted context omitted.

PEP-257 is where you can find documentation on them. https://www.python.org/dev/peps/pep-0257/

Thanks for that, and thank you for getting me into the whole PEP. Previously I had only heard about PEP 8, and I thought that was just it , an opinionated piece about how to write Python. Now I have a whole other source of information to look at. And for people who will no doubt call me out on this, I have been working on Zed's LPtHW for about a month. I have done numerous searches regarding Python problems, and this…

PEPs are basically the Python community's RFCs (if you're familiar with those).

BTW, what you call "an opinionated piece on how to write Python" was originally written by Guido van Rossum, the guy who invented Python in the first place. I think that gives him the right to say something on the topic...

(You ought to know that Python has a large following with a strong community feeling. Making negative remarks about their BDFL - benevolent dictator for life - van Rossum does not go down well ;-) )

Re: Ask HN: Good Python codebases to read?

#35
post #9

SQLAlchemy - https://github.com/zzzeek/sqlalchemy - http://www.aosabook.org/en/sqlalchemy.html - http://docs.sqlalchemy.org/en/rel_1_0/

You might actually find Dogpile (also by Mike Bayer) more approachable and useful in this context. Even the separation of the project into logically distinct packages is instructive.

- https://bitbucket.org/zzzeek/dogpile.core - https://bitbucket.org/zzzeek/dogpile.cache

Re: Ask HN: Good Python codebases to read?

#36
Jumping on the Kenneth Reitz train, you might check out The Hitchhiker's Guide to Python: http://docs.python-guide.org/en/latest/

He recommends the following Python projects for reading:

* Howdoi (https://github.com/gleitz/howdoi)

* Flask (https://github.com/mitsuhiko/flask)

* Werkzeug (https://github.com/mitsuhiko/werkzeug)

* Requests (https://github.com/kennethreitz/requests)

* Tablib (https://github.com/kennethreitz/tablib)

Hope that helps---good luck!

Re: Ask HN: Good Python codebases to read?

#38

Openstack does a large amount of testing for their code[1] but they is a huge amount of it. Barbican[2] is one of the newer less crufty components. [1]: https://github.com/openstack/openstack [2]: https://github.com/openstack/barbican

Openstack is so large it also has a plethora of examples of bad code. Especially in vendor-contributed drivers and such. I wouldn't pay attention to the code so much as the incredible infrastructure and process that manages it and improves it over time.

Seriously, I've seen "sychronization threads" that use no synchronization primitives that have a single bare exception handler trap the critical section. The handler just restarts the computation... leading to fun times.

Cinder also has an interesting problem in the explosion of ABC "mixins" used for constructing a backend driver. It went from 5 in the previous release to something like 25 presently. A patch to fix it: https://review.openstack.org/#/c/201812/

But even the process isn't perfect. I've seen patches that change a couple of log lines get dog-piled with -1 nit-picks about inconsequential wording and take months to get through.

Openstack is an interesting beast but it's not a good example if you're just learning, IMO.

Re: Ask HN: Good Python codebases to read?

#39
post #29

The django project is a good example of a large opensource project which has aged well. http://github.com/django/django

I know it is a good project, but would you recommend it for someone to read through the codebase? (Honestly, looking at the repo, I don't even know where to start if I wanted to do a read through. Has anyone created a map? :)

No, definitely no. Django aged well in terms of being alive, usable and comfortable to use in most usecases. But the codebase... Let me explain. Currently it works as "pay-to-get-a-feature" by crowdfounding. It not a bad thing, it gives good features we all need, but it is a bit sad fact when you look at Rails. So, it doesn't mean Django developers doesn't care about code, they care. But codebase is so big and complicated(because some code needs to be refactored)... it is common to see that some bug cannot be simply fixed by two lines, because some core member insists "this all should be reworked".

Re: Ask HN: Good Python codebases to read?

#40
post #29

The django project is a good example of a large opensource project which has aged well. http://github.com/django/django

I know it is a good project, but would you recommend it for someone to read through the codebase? (Honestly, looking at the repo, I don't even know where to start if I wanted to do a read through. Has anyone created a map? :)

Have you considered building something with Django and figuring out the magic as you go along??
Post reply on HN