[Tutor] Criticism / Suggestions
Bill Kranec
billk at fastmail.fm
Tue Mar 1 04:06:44 CET 2005
Hello,
So I think that I've 'completed' my first real Python program, and I
would appreciate any constructive criticism you all could offer. The
program deals with a question that my Dad asked me awhile ago, which was
"If twelve people want to divide into teams of two and play (golf)
against each other, can a series of rounds be constructed such that each
player is teammates with each other player only once, and play against
each other as opponents no more then 3 times" ( that last bit might or
might not be 'optimal'.
My program:
1. Defines a round as a list, for example [1,2,3,4,5,6,7,8,9,10,11,12],
meaning player 1 & player 2 vs. player 3 & player 4, etc. I have
generated all such possible rounds ( I think ).
2. Defines a tournament iterator object, which uses two functions,
checkTeammates and checkOpponents, to build a tournament satisfying the
above criteria.
Like I mentioned before, this is my first fairly complex program, and is
also my first real use of things like exceptions, objects, and list
comprehensions. Basically I would like to know weather or not I used
these structures properly, weather or not my syntax is good, and if
there are any places with potential for improvement. ( This version is
somewhat slow, but is much faster than previous versions that I have
written. ) I've tried to have as many comments as possible to help
readability.
Code aside, my algorithm may or may not be the best. Feel free to
suggest improvements.
The code is located at http://rafb.net/paste/results/lrd5DG32.html.
Thanks for any thoughts!
Bill
More information about the Tutor
mailing list