Live data from Hacker News

Ask HN: Good Python codebases to read?

news.ycombinator.com

11–20 of 153 posts

Re: Ask HN: Good Python codebases to read?

#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 very capable piece of software, and now I know it's well documented with tests makes it very relevant to my interests :)

Edit: I'm on windows, but I'm using vagrant with Ubuntu 14lts image for my development work. Specifically the data science vagrant box...

Re: Ask HN: Good Python codebases to read?

#12
post #7

Earlier quoted context omitted.

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.

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)

Re: Ask HN: Good Python codebases to read?

#13
post #3
post #2

Flask - https://github.com/mitsuhiko/flask . It's small, awesome and digestible.

Thanks! I am also looking into using Flask soon too. I dabbled in django for a while, but too much magic was happening and I am trying to learn.

Django is quite transparent when you learn enough of it. But there is a lot to learn.

Re: Ask HN: Good Python codebases to read?

#14
post #9

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

This one could be very interesting as I have decades of experience with DBs and SQL, so I was always wondering about ORMs, and sqlalchemy seems to be best in field at the moment.

Thanks for the recommendation.

Cheers!

Re: Ask HN: Good Python codebases to read?

#15
post #2

Flask - https://github.com/mitsuhiko/flask . It's small, awesome and digestible.

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.

Re: Ask HN: Good Python codebases to read?

#16
post #13
post #3

Earlier quoted context omitted.

Thanks! I am also looking into using Flask soon too. I dabbled in django for a while, but too much magic was happening and I am trying to learn.

Django is quite transparent when you learn enough of it. But there is a lot to learn.

I was talking about just using django to make a web app. It is awesome in that regard. But if I'm making a web app just for learning about the issues regarding making web apps, django is not suitable because that's it's job :)

But I am hoping to move into django eventually, but first I want tknow what is going on behind the curtain.

Re: Ask HN: Good Python codebases to read?

#18
post #12

Earlier quoted context omitted.

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.

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/

Re: Ask HN: Good Python codebases to read?

#19
post #2

Flask - https://github.com/mitsuhiko/flask . It's small, awesome and digestible.

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

Re: Ask HN: Good Python codebases to read?

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

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!
Post reply on HN