raise statement on a conditional expression

后端 未结 4 444
梦如初夏
梦如初夏 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条回答
  •  囚心锁ツ
    2020-12-29 04:02

    I like to do it with assertions, so you emphasize that that member must to be, like a contract.

    >>> def foo(self):
    ...     assert self.value, "Not Found"
    ...     return self.value
    

提交回复
热议问题