Есть ли способ узнать, в какой строке или операторе утверждение не удалось выполнить в блоке исключений?
Код: Выделить всё
try:
assert True
assert 7 == 7
assert 1 == 2
# many more statements like this
except AssertionError:
print 'Houston, we have a problem.'
print
print 'An error occurred on line ???? in statement ???'
exit(1)
Код: Выделить всё
assert 7 == 7, "7 == 7"
Подробнее здесь: https://stackoverflow.com/questions/115 ... ement-it-o
Мобильная версия