Live data from Hacker News

Ask HN: Good Python codebases to read?

news.ycombinator.com

21–30 of 153 posts

Re: Ask HN: Good Python codebases to read?

#21

NetworkX - https://networkx.github.io/ Good example of object-oriented programming patterns (mixins) in Python and module organization.

Thanks! Not sure if I am ready to take on OOP and mixins in Python yet, but I do like the idea of module organization so it's definitely on my list now.

Cheers!

Re: Ask HN: Good Python codebases to read?

#22
post #19

Earlier quoted context omitted.

Also MarkupSafe - https://github.com/mitsuhiko/markupsafe It's a little bit meta, but I had lots of "wow" moments. Also, it's a nice example of using C to speed up certain operations.

Thanks for this recommendation. I don't know if I will check it out right now, but it is on my list now because I am hoping to integrate C in Python when needs be. But I don't want to jump the gun :)

For that you might want to look at Cython.

Re: Ask HN: Good Python codebases to read?

#23
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!

That is actually a very cool idea, taking 2 codebases that work on the same domain and seeing the trade offs that each made.

Thank you! (And I had no idea that either bazaar or mercurial were written in Python, because them being 'serious' software I automatically assumed they were written in C. Color me stupid)

Re: Ask HN: Good Python codebases to read?

#25
post #18
post #12

Earlier quoted context omitted.

Thanks! As ironic(?) as this sounds, where is this doc feature documented? (Part of my learning is that I am trying hard to learn how to navigate the various Python documentation. For example, I had a hell of a time trying to find a list of format strings, as different sources refer to it as different things)

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 is literally the first time I have come across a PEP reference to look at beside PEP 8.

Re: Ask HN: Good Python codebases to read?

#27
post #11
post #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)

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…

The Python standard library is hit-or-miss. Some parts are really excellent code. Other parts are horribly hacky crap from 1990 that can’t be ripped out or improved for backwards-compatibility reasons.

Re: Ask HN: Good Python codebases to read?

#28

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

Cool, thanks, didn't realize openstack was Python. It may be too much for me to take on at my level, but it is definitely on my 'to look at' list.

Cheers!

Re: Ask HN: Good Python codebases to read?

#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? :)

Re: Ask HN: Good Python codebases to read?

#30
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…

The Python standard library is hit-or-miss. Some parts are really excellent code. Other parts are horribly hacky crap from 1990 that can’t be ripped out or improved for backwards-compatibility reasons.

Thanks for that input, that is exactly what I thought it would be. My problem is that I am not able to discern the crap from good at my level.
Post reply on HN