try:
content = my_function()
except:
exit('Could not complete request.')
上記のコードを変更して、の値をチェックして、文字列が含まれているかどうかを確認したいと思いcontentます。または 正規表現を使用することを考えましたが、それを;if 'stuff' in content:に合わせる方法がわかりません。try一致する場合はFalse、例外が発生します。もちろん、ifそのコードの後にいつでも追加できますが、そこにそれを詰め込む方法はありますか?
擬似コード:
try:
content = my_function()
if 'stuff' in content == False:
# cause the exception to be raised
except:
exit('Could not complete request.')