Suppose I have a python program where assert is used to determine how it should be, and I would like to capture the anomalies with a read-eval loop rather than throwing an AssertionError .
Of course I could
if (reality!=expectation): print("assertion failed"); import pdb; pdb.set_trace();
but this is much more ugly in code than a simple assert(reality==expectation) .
I could have pdb.set_trace() called in the except: block at the top level, but then I would lose the entire failure context, right? (I mean, stacktrace can be restored from an exception object, but not the value of the arguments, etc.)
Is there something like the --magic command line --magic that can turn the python3 interpreter into what I need?
Pypebros
source share