News for hackers. Stuff that matters.
Re:Ask HN: Good Python codebases to read? by tallerholler on Thursday July 16, 2015 @04:49PM (#9899802)
I would add the Django project to that list as it's a very large, mature, and successful open source python project - https://github.com/django/django
Re:Ask HN: Good Python codebases to read? by rectangletangle on Thursday July 16, 2015 @05:22PM (#9899949)
Django's source is very high quality. Though due to the large scope of the project, there are necessarily many layers of indirection, which may be a bit daunting for someone who is just starting out.

However reading the less abstract parts may help. For instance, the paginator is pretty self contained. https://github.com/django/django/blob/master/django/core/pag...

Re:Ask HN: Good Python codebases to read? by lqdc13 on Thursday July 16, 2015 @09:10PM (#9900840)
I disagree. A lot of code that does very little.

I prefer sklearn like https://github.com/scikit-learn/scikit-learn/blob/master/skl...

A lot of code that does a lot.

Bottle is nice on the web dev front.

https://github.com/bottlepy/bottle/blob/master/bottle.py

Re:Ask HN: Good Python codebases to read? by rtpg on Thursday July 16, 2015 @09:33PM (#9900893)
I really like the API of the framework, unfortunately some of the core elements suffer from being extremely stateful code

The "self.thing = bar" in one function that only gets used in some other function ( or even worse something only used in a companion class) pattern is super prevalent.

Might just be me but I think a lot of the older code suffers from massive locality problems that makes debugging framework bugs super tricky

Re:Ask HN: Good Python codebases to read? by rectangletangle on Friday July 17, 2015 @12:52AM (#9901310)
Honestly, I have to agree with you to an extent.

I think a lot of the issues involving overuse of state, are primarily related to using OO when a pure function would suffice. It's just too tempting to dynamically assign attributes to mutable instances.

To be fair, when Django is used properly it isn't usually an issue. Besides the queryset/model API is extremely nice, and at this point very polished.

Re:Ask HN: Good Python codebases to read? by tallerholler on Thursday July 16, 2015 @06:00PM (#9900146)
definitely agree.. I recently looked at the management command code as a reference when building some non-django scripts that use python argparse...

https://github.com/django/django/blob/master/django/core/man...

Re:Ask HN: Good Python codebases to read? by alexchamberlain on Thursday July 16, 2015 @06:12PM (#9900210)
Is the Django project Pythonic? I mean, on the one hand, Python is the language of bells and whistles builtin. On the other hand, packages are encouraged to be simple and to the point.

Whilst this wasn't a discussion on which framework is best (and I'm not a Web dev by trade either), I must say I turn to Flask, as I find the API more Pythonic.

I guess what I'm trying to say is that the Django source code is probably great, but the less heavyweight packages/frameworks the better. Learn Pythonic API design from somewhere else.