Hi,

Why is it i can use mu custom class exception without creating an exception
object first?

Thanks


   1. class ShortInputException(Exception): def __init__(self, length,
    atleast):
   2.         Exception.__init__(self)
   3.         self.length = length
   4.         self.atleast = atleast
   5. try:
   6. text = input() if len(text) < 3:
   7. raise ShortInputException(len(text), 3) # Other work can continue as
   usual here
   8. except EOFError:
   9. print()
   10. except ShortInputException as ex:
   11. print(\
   12. .format(ex.length, ex.atleast)) else:
   13. print()
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to