Well written open source Python apps

Discussion in 'Python' started by Ben, Oct 13, 2005.

  1. Ben

    Ben Guest

    Could anyone suggest an open source project that has particularly well
    written Python? I am especially looking for code that people would
    describe as "very Python-ic". (Not trying to start any kind of war -
    just wanted some good examples of a well written Python app to read.)

    Thanks!
    -Ben

    P.S. - Sorry if this has been discussed at length before - I searched
    the group before I posted, but didn't come up with what I was looking
    for.
    Ben, Oct 13, 2005
    #1
    1. Advertising

  2. On Thursday 13 October 2005 09:43, Ben wrote:
    > Could anyone suggest an open source project that has particularly
    > well written Python? I am especially looking for code that people
    > would describe as "very Python-ic". (Not trying to start any kind of
    > war - just wanted some good examples of a well written Python app to
    > read.)


    The Python Standard Library. Thousands of lines of quite good Python
    code. It might not use all the latest features, and there might be a
    few dark corners here and there, but it's still solid. And quite easy
    to understand (I had no difficulty understanding and modifying
    httplib).

    - Michael
    Michael Ekstrand, Oct 13, 2005
    #2
    1. Advertising

  3. On Oct 13, Ben wrote:
    > Could anyone suggest an open source project that has particularly well
    > written Python? I am especially looking for code that people would
    > describe as "very Python-ic". (Not trying to start any kind of war -
    > just wanted some good examples of a well written Python app to read.)


    The Python Package Index (PyPI, or cheeseshop)
    <http://www.python.org/pypi> has pointers to a lot of packages that are
    likely mostly pythonic.

    I don't know if this is spelled out more precisely somewhere, but here
    is my notion of a pythonic distribution:

    * Has modules grouped into packages, all are cohesive, loosely
    coupled, and reasonable length

    * Largely follows PEP <http://www.python.org/peps/> conventions

    * Avoids reinventing any wheels by using as many Python-provided modules
    as possible

    * Well documented for users (manpages or other) and developers
    (docstrings), yet self-documenting with minimal inline commenting

    * Uses distutils for ease of distribution

    * Contains standard informational files such as:
    BUGS.txt COPYING.txt FAQ.txt HISTORY.txt README.txt THANKS.txt

    * Contains standard directory structure such as:
    doc/ tools/ (or scripts/ or bin/) packageX/ packageY/ test/

    * Clean UI, easy to use, probably relying on optparse or getopt

    * Has many unit tests that are trivial to run, and code is structured to
    facilitate building of tests

    The first example of a pythonic package that comes to my mind is
    docutils <http://docutils.sourceforge.net/>.

    --
    Micah Elliott
    <>
    Micah Elliott, Oct 13, 2005
    #3
  4. Ben

    Steve M Guest

    Steve M, Oct 13, 2005
    #4
  5. This is really synchronicity in action! I started to think yesterday
    about putting together a project that measures the 'goodness' of Python
    packages in the PyPI Cheese Shop repository. I call it the "Cheesecake"
    project. I took the liberty of citing Micah's post in a blog entry that
    I just posted:
    <http://agiletesting.blogspot.com/2005/10/cheesecake-how-tasty-is-your-code.html>

    Comments/suggestions welcome!

    Grig
    Grig Gheorghiu, Oct 13, 2005
    #5
  6. Ben

    John J. Lee Guest

    "Ben" <> writes:

    > Could anyone suggest an open source project that has particularly well
    > written Python? I am especially looking for code that people would
    > describe as "very Python-ic". (Not trying to start any kind of war -
    > just wanted some good examples of a well written Python app to read.)

    [...]

    At the time I looked at it I thought this was nice, though that was
    some time ago (it was still 'sketch' then) so I wonder if I'd still
    have the same opinion if I looked now (due to me changing my view of
    "good code", not the skencil source code changing!):

    http://www.nongnu.org/skencil/


    John
    John J. Lee, Oct 13, 2005
    #6
  7. On Oct 13, Grig Gheorghiu wrote:
    > This is really synchronicity in action! I started to think yesterday
    > about putting together a project that measures the 'goodness' of Python
    > packages in the PyPI Cheese Shop repository. I call it the "Cheesecake"
    > project. I took the liberty of citing Micah's post in a blog entry that
    > I just posted:
    > <http://agiletesting.blogspot.com/2005/10/cheesecake-how-tasty-is-your-code.html>


    Grig, I think you're onto something here; good idea. I have no
    experience with CPANTS, and I'm not sure how many of my ideals could be
    checked programmatically. But if your Cheesecake tool comes into
    fruition, here are some things that I would personally find useful:

    * A command-line version that I could easily run on my projects.

    * An output that gives more than just an index/score; maybe a bunch of
    stats/indicators like pylint. I.e., it would be say "pypkglint" or
    "pydistchecker", a higher level lint that operates on packages instead
    of just source files.

    * Some checks that might be useful

    - Module and package naming conventions. (PEP-8 describes
    module-naming, but I see this broken more often than followed in
    practice. And it is silent on package names, but the tutorial uses
    capitalized names.) Some consistency here would be nice.

    - Existence of standard files. ESR goes into detail on this in his
    "Art of UNIX Programming" book (pp 452).

    - Existence of standard directories (those I mentioned before).

    - Output of checkee "--help" should satisfy some standards. I presently
    check my own tools by running "help2man" which forces me to setup
    optparse to follow a strict format. I have some active RFEs on
    optik (optparse) to address this.

    - Use of distutils. Maybe just a check for setup.py ?

    - Consistency of module length. Not sure about this one, but you
    might lower the score if some package modules are 10 lines while
    others are 10KLOC.

    - Number of modules per package. Maybe 4..20 is a good amount?

    - Extra points for existence of something like "api.html", which
    indicates that epydoc/pydoc generated API info.

    - Extra points for .svn/CVS/RCS directories indicating that version
    control is in place. Maybe even glarking of version numbers where
    high numbers indicate that code is checked in frequently.

    - Use of ReST in documentation, or even in docstrings.

    - Count of unit tests. Do module names map to test_<modulename> in
    test directory? How many testXXX functions exist?

    - A summary calculation of pylint/pychecker scores for each module.

    - Point deduction (or fail!) if any .doc/.xls, etc. files included in
    distribution.

    - Extra points for use of modules that indicate extra usability was
    incorporated, such as: gettext (multi-language), optparse (clean
    UI), configparser (fine control), etc.

    * A PEP describing the conventions (though some will argue that PEPs
    should be enforcable by the compiler, so maybe just a "Cheesecake
    Convention" document).

    * And of course anything that CPANTS offers :)

    I'm sure people here have more ideas for quality indicators...

    --
    Micah Elliott
    <>
    Micah Elliott, Oct 13, 2005
    #7
  8. Ben

    Peter Hansen Guest

    Ben wrote:
    > Could anyone suggest an open source project that has particularly well
    > written Python? I am especially looking for code that people would
    > describe as "very Python-ic". (Not trying to start any kind of war -
    > just wanted some good examples of a well written Python app to read.)


    I'm sorry I can't speak on its "pythonicity" (my memory sucks), but I
    did find Roger Binns' BitPim program (http://bitpim.sourceforge.net/) to
    be an excellent source of ideas (steal steal steal) for wxPython code,
    and I do remember it struck me as being exceptionally well commented and
    well structured. I suspect it's pretty Pythonic, too, since Roger seems
    pretty brilliant from where I sit. :)

    -Peter
    Peter Hansen, Oct 14, 2005
    #8
  9. Ben

    B Mahoney Guest

    B Mahoney, Oct 14, 2005
    #9
  10. > Could anyone suggest an open source project that has particularly well
    > written Python? I am especially looking for code that people would
    > describe as "very Python-ic".


    I vote for the "doctest" code in the standard library.

    Michele Simionato
    Michele Simionato, Oct 14, 2005
    #10
  11. Ben

    Gerrit Holl Guest

    Ben wrote:
    > Could anyone suggest an open source project that has particularly well
    > written Python? I am especially looking for code that people would
    > describe as "very Python-ic". (Not trying to start any kind of war -
    > just wanted some good examples of a well written Python app to read.)


    Mailman - http://www.list.org/
    Spambayes - http://www.spambayes.org

    Those are written by experienced Python programmers, some of them Python
    developers. It looks like well written code to me.

    Gerrit.

    --
    Temperature in Luleå, Norrbotten, Sweden:
    | Current temperature 05-10-14 10:19:49 8.3 degrees Celsius ( 47.0F) |
    --
    Det finns inte dåligt väder, bara dåliga kläder.
    Gerrit Holl, Oct 14, 2005
    #11
  12. Ben

    Guest

    Steve M wrote:
    > Here is an article discussing the coding style of BitTorrent.
    >
    > http://www.onlamp.com/pub/a/python/2003/7/17/pythonnews.html
    >
    > Maybe that code is worth looking at.


    [didn't read this thread or that article until I saw the summary in Dr.
    Dobb's Python-URL]

    FWIW, the BitTorrent code seemed like an incredible hack to me. The
    above article tries to put a positive spin on it, but seriously, the
    code was a mess. Hats off to Mr. Cohen for creating BitTorrent in the
    first place, but I wouldn't go looking at that code for any "best
    practices".

    It took several days of head scratching to figure out what was really
    going on because the code is almost *completely* devoid of comments -
    even high level stuff like "this module is for X" or "this class does
    Y", not to mention comments to clarify code that was obscure or trying
    to be too cute.

    A day or so into it I discovered that there were two different public
    classes with the exact same name, so anytime you saw it used elsewhere
    you had to dig around to figure out which class was being used.

    There were also lots of more subjective things that were pretty
    annoying - state was passed around in various dictionaries (they were
    begging to be refactored into classes), a lot of the variable names
    seemed like misnomers, values were passed out from functions via 1-item
    lists, etc. - drove me nuts. :)

    To be clear, I'm not trying to rag on BitTorrent, just pointing out
    that it is probably not at all what the OP is looking for (well-written
    Python, stuff that is generally considered "very Pythonic").

    -Dave
    , Oct 17, 2005
    #12
  13. Paulo Eduardo Neves, Oct 18, 2005
    #13
  14. Ben

    Misto . Guest

    Misto ., Oct 19, 2005
    #14
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Python Baby
    Replies:
    4
    Views:
    436
    Lothar Scholz
    Feb 16, 2004
  2. Replies:
    0
    Views:
    1,147
  3. R.A.M.
    Replies:
    11
    Views:
    584
    dorayme
    Nov 19, 2006
  4. Well-written open source?

    , Nov 5, 2005, in forum: C Programming
    Replies:
    3
    Views:
    412
  5. Laura Creighton
    Replies:
    5
    Views:
    1,222
    Rick Kwan
    May 28, 2008
Loading...

Share This Page