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?
In that case
read_file()would get executed twice. You can do this instead: