News for hackers. Stuff that matters.
Re:Reasons Python Sucks by saagarjha on Tuesday December 18, 2018 @08:18PM (#18712216)
This is extremely heavyweight syntax for something I like to use as a lightweight construct. If I wanted a function, I would make something a function.
Re:Reasons Python Sucks by dontreact on Tuesday December 18, 2018 @09:30PM (#18712542)
x = lambda y: <code goes here>

def x(y): <code goes here>

What's so heavyweight? A new line and a tab?

Re:Reasons Python Sucks by lou1306 on Wednesday December 19, 2018 @05:33AM (#18714686)
IMO lambdas are useful because they reduce mental overhead by allowing the developer not to give names to trivial functions [1]. Compare these two equivalent pieces of code:

    youngest_person = min(people, key=lambda x: x.age)

    def get_age(x):
        return x.age
    youngest_person = min(people, key=get_age)
This may not seem like a huge difference, but using lambdas scales better.

[1] Incidentally, this is the same reason why I don't miss multi-line lambdas (in Python): multi-line functions are seldom trivial.

Re:Reasons Python Sucks by dontreact on Thursday December 20, 2018 @07:03PM (#18730388)
Yeah in the context of multi line functions the overhead is

A new line A tab A return

This does not sound heavyweight to me (in that context). In the context of a single line function I see the utility of lambdas.