Live data from Hacker News

Ask HN: Good Python codebases to read?

news.ycombinator.com

71–80 of 153 posts

Re: Ask HN: Good Python codebases to read?

#71
post #69

The Nylas Sync Engine is a large Python codebase with a test suite: https://github.com/nylas/sync-engine Lots of examples of SQLAlchemy, Flask, gevent, and pytest in action to build a REST API and sync platform for email/calendar/contacts data!

Putting on my "Python teacher" hat for a moment (I also work at Nylas), our codebase is interesting for learning purposes because it's a fairly homogenous, 'live' product managed by a commercial engineering team. Definitely on the complex side of things, though -- let me know if you want any help figuring it out (we also have a community Slack at http://slack-invite.nylas.com/).

On the testing side, I was chatting to a fellow Pyladies attendee about how we do test fixture setup and teardown (especially around databases) -- you might find that interesting to look at too.

Re: Ask HN: Good Python codebases to read?

#72
post #34
post #25

Earlier quoted context omitted.

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 t…

I think you'll find lots of people in the Python community who think that Python 3 was a mistake, that GvR's insistence on artificially weakening lambdas is a mistake, etc. Disagreeing with style is pretty minor.

Doesn't make it any less of a community. Families can disagree with each other and still love each other.

Re: Ask HN: Good Python codebases to read?

#73
post #16
post #13

Earlier quoted context omitted.

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.

I agree, Django is likely not the best if you're just starting learning, and writing a webapp from scratch. Working in an existing codebase, with other devs of whom you can ask questions, is a luxury that I was very thankful for.

I use Django at work, and it was my first time with Python. The beauty of Django is, IT'S ALL SOURCE. When you run it locally, you have TONS of learning options:

- Get an IDE, and read the sources if you don't understand how something works. "Find-Definition" all the way down. (I heart PyCharm.)

- If something's broken, you can edit it!

- You can put in `import ipdb; ipdb.set_trace()` calls anywhere and get a debugging prompt! (If you don't have IPython, you can use `pdb` instead of `ipdb`... shudder.) Being able to print What Actually Gets Passed Around can occasionally be very helpful.

- You can put in debugging messages at multiple points in the flow!

- make a `pygrep` alias to answer "where is ..." questions:

  # ignore south migrations, and external libraries.
  # You can alter this if you care about reading libs' codebase
  alias pygrep='grep -rin --include=*.py --exclude=*.pyc --exclude-dir=lib --exclude-dir=migrations'

Re: Ask HN: Good Python codebases to read?

#74
post #67

Earlier quoted context omitted.

requests is very useful, but it always gets mentioned as a good python codebase and I'm not sure I agree. One example: The first thing many users will do is requests.get? Which tells them that it takes some kwargs, but doesn't tell them what those kwargs are. It's easy, especially for a newcomer, to read "optional arguments that `request` takes" and fail to understand that they should look up the docs on (not-really-…

Looks like you did the legwork of listing the params already, so you might as well send a PR with that docstring.

OK, maybe I will open an issue. The obvious concern is how to avoid duplicating the text among the various HTTP verb functions. In theory python allows the docstring to be manipulated via __doc__. However I don't think there is a precedent for using that mechanism to avoid duplication of docstring content that is considered good style, but perhaps someone could correct me if that is wrong.

Re: Ask HN: Good Python codebases to read?

#75
Mercurial.

By design, Mercurial has almost no dependencies, so it's very self-contained. I find this makes it a particularly easy codebase to get into.

If you're interested, I would love to walk you (or anyone else!) trough it.

Re: Ask HN: Good Python codebases to read?

#76
post #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!

Large pieces of SQLAlchemy are about metaprogramming and some syntactic magic required for an easy-to-use ORM. It's mostly nice on the inside (to my cursory glance), but neither simple nor easy for an inexperienced person.

Still it's a good example how to make many relatively complex parts easily composable and efficient.

Re: Ask HN: Good Python codebases to read?

#77
post #69

The Nylas Sync Engine is a large Python codebase with a test suite: https://github.com/nylas/sync-engine Lots of examples of SQLAlchemy, Flask, gevent, and pytest in action to build a REST API and sync platform for email/calendar/contacts data!

I clicked through on this and browsed a few directories, none of which seemed likely. I do not see any `.py` files aside from an empty `__init__.py` and the `setup.py`. Are you sure a beginner just learning Python should see this?

Re: Ask HN: Good Python codebases to read?

#78

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

I don't know what would be of my life right now without Django and I can't praise it enough... but "good example of readable python-code", it is not.

I learned a lot from reading the Django codebase. I didn't read it like a book, I read parts of it as I tried to figure out how to do things in Django, but I never felt like the code was bad. This was around 5 years ago so it's possible things have gotten more convoluted since then.

If the OP wants to grok a small, discrete codebase then I agree that Django is not what he's looking for.

Re: Ask HN: Good Python codebases to read?

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

For the benefit of other novice like me, here [0] is the index for all PEPs.

[0]https://www.python.org/dev/peps/

Post reply on HN