cute use of lambda
tjreedy at udel.edu
Sat Sep 29 03:55:35 CEST 2007
"Simon Forman" <sajmikins at gmail.com> wrote in message
news:1190945901.551940.165240 at k79g2000hse.googlegroups.com...
| class FakeQueue(list):
| put = list.append
| get = lambda self: self.pop(0)
Sorry, to me this is a foolish use of lambda as it is exactly the same as
def get(self): self.pop(0)
except that in the latter, the resulting function object gets a proper
internal name instead of '<lambda>', therefore giving a more informative
traceback in case of an exception.
More information about the Python-list