bool value of a list in Python

后端 未结 4 513
名媛妹妹
名媛妹妹 2021-01-18 05:45

what is the best way to turn a list into bool value? I am looking for something like:

return eval_bool(my_list)

I have a custom container i

4条回答
  •  借酒劲吻你
    2021-01-18 06:26

    You can use ternary "if" operator. Google says it supported since 2.5

    foo = True if your_list else False
    

提交回复
热议问题