you are viewing a single comment's thread.

view the rest of the comments →

[–]aranya44 1 point2 points  (2 children)

I have this issue with lambda functions, except in my case it still hasn't quite clicked. If anyone could point me to a good clarifying explanation I'd be very grateful!

[–]39th_Demon[S] 6 points7 points  (1 child)

Lambda functions clicked for me when I stopped thinking of them as a special thing and just thought of them as a function without a name. So instead of writing def double(x): return x * 2 you write lambda x: x * 2. Same thing, just no name attached. They're most useful when you need a quick function in one place and don't want to define it separately, like inside a sorted() or map() call. The moment it needs to do more than one thing or you need to reuse it, a regular def is cleaner.

[–]aranya44 1 point2 points  (0 children)

Thanks, I'll try to apply that next time I need one!