In the context that "one should read and analyze source code written by great programmers to become a better programmer," Jarno Virtanen asks "what would you recommend as a sort of source code literature to study?"
It's a good question. I don't know anything about truely great software, but source code that's been particularly inspiring to me lately in the Python realm has been:
- Docutils - the document processing framework for reStructuredText.
- APE - An adaptable persistence system that plugs into Zope/ZODB to not only offer good object-relational mapping, but also object-file (ie - an editable, understandable file) mapping, and the possibilities for anything else.
- Zope 3 - Zope 2 is some of the worst Python code to take good examples from (a little bit too much cleverness, and also strange namespace population games). Zope 3, on the other hand, maintains well structured packages and modules, and backs away from the package/module/class name collision (ie - no "is it 'DateTime.DateTime.DateTime'? or 'DateTime.DateTime' that I should import?). While you can now end up with long full names like
zope.app.browser.form.editform.EditView
, in Zope 3 you can easily trace that down to the class 'EditView'.
And while I haven't looked at the source code of
Twisted, its API documentation looks as if it's all in this style as well. I count all of the above as good Python style. Many of the newer additions to the Python standard library (particularly large subsystems like the new email package and distutils) seem to follow these guidelines as well. It's funny, however, to see some newer Zope 2 products claim "follows Zope 3 conventions." These conventions have always been there, Zope 2 just seemed not to promote them.
I also found myself being particularly impressed with the C source code for Ruby. I found it much easier to read than most of the C source for Python (at least, based on the few glimpses I've put into each).