def isBig(x):
if x > 4:
return \'apple\'
else:
return \'orange\'
This works:
if isBig(y): return isBig(y)
You could use a generator:
def ensure(x):
if x: yield x
for fruit in ensure(isBig(y)):
return fruit
If you want to code in PHP (or C), code in it. Don't try to force its methods onto another language.
One of the basic tenets behind Python (in my opinion) is its readability. You should be using:
fruit = isBig(y)
if fruit: return fruit
I should also mention that your use of isXXX()
is very strange; it's usually used to return boolean values. Especially in this case where you're using it in an IF
statement.