By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,275 Members | 1,745 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,275 IT Pros & Developers. It's quick & easy.

Well written open source Python apps

P: n/a
Ben
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.

Oct 13 '05 #1
Share this Question
Share on Google+
13 Replies


P: n/a
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
Oct 13 '05 #2

P: n/a
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
<md*@micah.elliott.name>
Oct 13 '05 #3

P: n/a
Here is an article discussing the coding style of BitTorrent.

http://www.onlamp.com/pub/a/python/2...ythonnews.html

Maybe that code is worth looking at.

Oct 13 '05 #4

P: n/a
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

Oct 13 '05 #5

P: n/a
"Ben" <bw*******@gmail.com> 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

Oct 13 '05 #6

P: n/a
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
<md*@micah.elliott.name>
Oct 13 '05 #7

P: n/a
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
Oct 14 '05 #8

P: n/a
The paper on BitPim http://bitpim.sourceforge.net/papers/baypiggies/
lists and describes programs and ideas used for the project. Some of
it is just bullet-points, but everything seems to be well chosen. I've
swiped a lot of these ideas.

Oct 14 '05 #9

P: n/a
> 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

Oct 14 '05 #10

P: n/a
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.
Oct 14 '05 #11

P: n/a
Steve M wrote:
Here is an article discussing the coding style of BitTorrent.

http://www.onlamp.com/pub/a/python/2...ythonnews.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 '05 #12

P: n/a
This is an old thread in this subject that I bookmarked:
http://groups.google.com/group/comp....93a0b7722bb32f

Oct 18 '05 #13

P: n/a
I suggest also these:

Spark:
-----------------
http://pages.cpsc.ucalgary.ca/~aycock/spark/

Few files.
I like how doc strings are used for handling the grammar.
Twisted:
----------------
http://twistedmatrix.com/

I like everything, from test to comments! (many are funny)
Misto
Oct 19 '05 #14

This discussion thread is closed

Replies have been disabled for this discussion.