Live data from Hacker News

Ask HN: Good Python codebases to read?

news.ycombinator.com

1–10 of 153 posts

Ask HN: Good Python codebases to read?

#1
Hi all, I am currently going through Learn Python the Hard Way, and am on the review section where I have to read through source code.

Can anyone recommend some good open source Python software I can look at? I am specifically looking to see ones that employ idiomatic Python, and maybe see how they approach testing (I am not completely new to programming, just rusty after being out of the field for a long time)

Extra bonus points if the software is something you use regularly.

Cheers!

Re: Ask HN: Good Python codebases to read?

#5
Really the hard way?

https://hg.python.org/cpython/file/3.5/Lib/collections/__ini... Knowing specialized data structure in a language is always important and this is well coded.

Well see the 2 lines I pointed in one of the standard library in python and you will understand that even in good language there will always be dust under the carpet at one point. https://hg.python.org/cpython/file/5c3812412b6f/Lib/email/_h...

Re: Ask HN: Good Python codebases to read?

#6
post #4

Requests - https://github.com/kennethreitz/requests . How to make a usable api. The decisions that went into each method call were fantastic. Great test coverage as well. I use package in most python development.

Thanks, I've been hearing a lot about this package, I think it's one I will check out.

Cheers!

Re: Ask HN: Good Python codebases to read?

#7
post #5

Really the hard way? https://hg.python.org/cpython/file/3.5/Lib/collections/__ini... Knowing specialized data structure in a language is always important and this is well coded. Well see the 2 lines I pointed in one of the standard library in python and you will understand that even in good language there will always be dust under the carpet at one point. https://hg.python.org/cpython/file/5c3812412b6f/Lib/email/_h..…

Thanks for the recommendations, I think they may be a bit above me at the moment (I don't have enough knowledge of Python to be able to identify dust under the carpet :)

But you did teach me one thing, I didn't know that the """ could be used for commenting. I thought it was only for multi-line print statements.

These are exactly the type of things I hope to learn while code-reading.

Cheers!

Re: Ask HN: Good Python codebases to read?

#8
1. The Python standard library (if you're on Linux, /usr/lib/python2.x or 3.x, depending on your version).

2. The Bazaar VCS is written entirely in Python, is very well documented and has a large test section. (www.launchpad.net/bzr)

Re: Ask HN: Good Python codebases to read?

#10
post #7
post #5

Really the hard way? https://hg.python.org/cpython/file/3.5/Lib/collections/__ini... Knowing specialized data structure in a language is always important and this is well coded. Well see the 2 lines I pointed in one of the standard library in python and you will understand that even in good language there will always be dust under the carpet at one point. https://hg.python.org/cpython/file/5c3812412b6f/Lib/email/_h..…

Thanks for the recommendations, I think they may be a bit above me at the moment (I don't have enough knowledge of Python to be able to identify dust under the carpet :) But you did teach me one thing, I didn't know that the """ could be used for commenting. I thought it was only for multi-line print statements. These are exactly the type of things I hope to learn while code-reading. Cheers!

Even better: If you put the string right after your function/class definition, python automatically assigns it to the `__doc__` attribute of the object. This is how the `help` function works.
Post reply on HN