Hacker News new | ask | show | jobs
by uryga 2180 days ago
what do you think about if-expressions?

  x if cond else y
IMO match-expressions have basically the same benefits/trade-offs.
2 comments

Match are usually much more complex than a single ternary condition. Allow to inline them and you will see monsters in the wild.

But I do wish they would have not set aside generalized unpacking.

> Allow to inline them and you will see monsters in the wild.

idk... you can write a huge ugly if-elif-else like this:

  a if foo else b if bar else c if quux else d
but most people just don't.
Ternary expressions are not covered by python code coverage tools by the way.
interesting! why not?
Bytecode tracing is new in 3.7, and nobody's used it in coverage.py yet.