Which exception to use?

Edward C. Jones edcjones at erols.com
Tue Jan 28 14:39:01 EST 2003


Which exception is it best to use in the following pieces of code?

if len(sys.argv) != 2:
     raise SomeException, 'program requires exactly one argument'

if len(sometuple) != 3:
     raise SomeException, 'sometuple must have length 3'

I use TypeError or ValueError but they don't feel right. I wish there 
was a SizeError or LengthError.





More information about the Python-list mailing list