raise statement on a conditional expression

后端 未结 4 479
梦如初夏
梦如初夏 2020-12-29 03:38

Following \"Samurai principle\", I\'m trying to do this on my functions but seems it\'s wrong...

return  if  else raise 

        
4条回答
  •  -上瘾入骨i
    2020-12-29 04:26

    Well, you could test for the bool separately:

    if expr: raise exception('foo')
    return val
    

    That way, you could test for expr earlier.

提交回复
热议问题