cute use of lambda
Kay Schluehr
kay.schluehr at gmx.net
Sat Sep 29 00:12:29 EDT 2007
On 29 Sep., 03:55, "Terry Reedy" <tjre... at udel.edu> wrote:
> "Simon Forman" <sajmik... 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)
Better use
def get(self): return self.pop(0)
otherwise you will *get* nothing ;)
BTW I wonder why a destructive operation is named *get* instead of
*take* ?
More information about the Python-list
mailing list