Problem with Unittest - Thanks:
Terry Reedy
tjreedy at udel.edu
Wed May 14 14:26:52 EDT 2003
"Frithiof Andreas Jensen" <frithiof.jensen at removethis.ted.ericsson.dk>
wrote in message news:b9tn02$5ac$1 at newstree.wise.edt.ericsson.se...
>
> Is it legal, moral and commendable to raise exceptions like: 'raise
> ValueError('some explanation text')?
For the dubious: Ref Manual, 6.9 The raise statement
"Otherwise, raise evaluates its first expression, which must yield a
string, class, or instance object. .... If the first expression is an
instance object, the second expression must be None." [or omitted,
unless third expression is present]
try:
raise Exception("Test of instance raising")
except Exception, haha:
print haha, type(haha)
#prints
Test of instance raising <type 'instance'>
Terry J. Reedy
Terry J. Reedy
More information about the Python-list
mailing list