So here's a simple object creation and assignment using a 1 line ternary expression in Java.
Interval newInterval = previous.end <= current.end ? new Interval(previous.start, current.end : new Interval(previous.start, previous.end)
The python equivalent is,
new_interval = Interval(previous.start, current.end) if previous.end <= current.end else Interval(previous.start, previous.end)
My question is there a more pythonic way to write this?
new_interval = Interval(previous.start, current.end if previous.end <= current.end else previous.end)seems more reasonable to me (in both languages).