News for hackers. Stuff that matters.
Re:It Takes 6 Days to Change 1 Line of Code by nicwolff on Sunday July 16, 2023 @12:44PM (#36748951)
11 ways of thinking!

    if not something:
        # Unhappy case
        return
    # Happy case
Re:It Takes 6 Days to Change 1 Line of Code by nickjj on Sunday July 16, 2023 @01:26PM (#36749446)
Yep, personally I think that's ok too.

It's mainly avoiding the "if not else" pattern in 1 condition. I haven't met anyone who fully agrees that it's easier to read than "if happy else unhappy" or returning early with whatever condition makes sense for the function.

Re:It Takes 6 Days to Change 1 Line of Code by Izkata on Sunday July 16, 2023 @01:47PM (#36749687)
This one specifically has a name, that if statement (including the early return) is a guard clause.