cute use of lambda

Terry Reedy tjreedy at
Sat Sep 29 03:55:35 CEST 2007

"Simon Forman" <sajmikins at> wrote in message 
news:1190945901.551940.165240 at
| 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 mailing list