News for hackers. Stuff that matters.
Re:Ask HN: Machine Learning Engineers, what do you do at work? by eb0la on Saturday June 08, 2024 @01:50PM (#40619183)
I haven't touched Perl in more than 20 years... ... but I (routinely) miss something like:

   $variable = something() if sanity_check()
And

   do_something() unless $dont_do_that
Re:Ask HN: Machine Learning Engineers, what do you do at work? by jononor on Saturday June 08, 2024 @06:17PM (#40620550)
There exists a ternary if statement?

foo = something() if sanity_check else None

Can replace None with foo (or any other expression), if desired.

Re:Ask HN: Machine Learning Engineers, what do you do at work? by reportgunner on Sunday June 09, 2024 @11:32AM (#40625116)
Both work in python:

        variable = something() if sanity_check() else None


        do_something() if not dont_do_that else None
Re:Ask HN: Machine Learning Engineers, what do you do at work? by c6401 on Monday June 10, 2024 @07:22AM (#40632365)
Additionally to the provided answers:

if sanity_check(): variable = something()

variable = sanity_check() and something

(but the standard python two line way is more readable unless it's a throwaway single use code, then whatever)