Seebs wrote:
On 2010-10-21, Jean-Michel Pichavant <jeanmic...@sequans.com> wrote:
Let me quote the paper I linked in the previous post:
list1 = []
for x in theList:
if x[0] == 4:
list1 += x;
return list1
compare it to:
flaggedCells = []
for cell in theBoard:
if cell[STATUS_VALUE] == FLAGGED:
flaggedCells += cell
return flaggedCells
The latter is better, but:
flagged = []
for cell in board:
if cell.flagged():
flagged += cell;
is probably even better.
[snip]
-s
Right, may be there is an even better solution. This is not the point.
The point of this example is to show the power of meaningful names in a
very basic example. You said it yourself, the latter is better.
JM
--
http://mail.python.org/mailman/listinfo/python-list