Pythonic方式编写级联if语句

sno*_*und -1 python if-statement

是否有更多的Pythonic方式来编写以下函数?

def foo():
    flag = False
    if condition1:
        if condition2:
            flag = True
    return flag
Run Code Online (Sandbox Code Playgroud)

Bid*_*rai 5

干得好:

def foo():
    return bool(condition1 and condition2)
Run Code Online (Sandbox Code Playgroud)