Do Python Inline if statements execute a function twice?

python

Solution

In that case `read_file()` would get executed twice. You can do this instead:

variable = read_file() or "File was empty"

Problem

When I do something like (totally random example dont read into variable names): ``` variable = read_file() if read_file() else "File was empty" ``` In this case does read_file() get excuted twice? If so is there a way to do it to only execute once but keep it within one line?

Original source