Re:Ask HN: is it a good idea in Python? If yes, how to make ...
by d0mine on Tuesday February 10, 2009 @01:47PM
(#475657)
Your examples rewritten in a different style:
table = ((8, 2, 9), (4, 5, 6), (2, 1, 9))
my_sum = sum(row[0] for row in table if row[2] == 9)
# assert my_sum == 10
my_lst = [row[0] for row in table if row[2] == 9]
# all row[2] == 9 therefore OrderBy is a no-op in your example
# assert my_lst == [8, 2]
Re:Ask HN: is it a good idea in Python? If yes, how to make ...
by russell on Tuesday February 10, 2009 @12:50PM
(#475546)
Lambdas pretty much suck because there has not been a good brace-free syntax proposal, There was a pretty good proposal for a where clause a couple of years ago, but it doesn't seem to have gotten any traction, probably because it was not made into a PEP (see python.org about PEP's).
Re:Ask HN: is it a good idea in Python? If yes, how to make ...
by gaius on Tuesday February 10, 2009 @12:18PM
(#475494)
From the article:
#
#Problem: all these lambdas suck. Any better ways to do it?
#
#
#TODOS/QUESTIONS:
#
#1. is it a good idea?
#
#2. can it be made to not suck (do something with all those lambdas)?
Re:Ask HN: is it a good idea in Python? If yes, how to make ...
by run4yourlives on Tuesday February 10, 2009 @12:46PM
(#475538)
Issue being that how can anyone answer those two questions without understanding the problem he/she is attempting to solve?
It very well might be the only way to solve the issue given external constraints, but it may also be the case that, for example, reworking the problem space would lend itself to a much more elegant solution.
Code should never be treated as if it exists in some sort of bubble.
http://groups.google.com/group/comp.lang.python/browse_threa...
It very well might be the only way to solve the issue given external constraints, but it may also be the case that, for example, reworking the problem space would lend itself to a much more elegant solution.
Code should never be treated as if it exists in some sort of bubble.