[Tutor] Custom objects throw what exception?

Thanos Panousis pthanos at gmail.com
Wed Apr 25 09:42:09 CEST 2007


The tutor list is definately helping me perform my OO-python babysteps.

I want to ask this. Say I have some objects of my own, and using the
example I posted in a previous post, say I have a person object with a
instance variable called hairColor.

The hairColor property is set via an exotic function that could go
wrong and produce an exception.

How should I hanlde this? Should I catch the exception in the
person.__init__(self,color) "construtor"? and if I do so, what happens
the code that is waiting for a person object to arrive with a call
like p = person(). What exception should the person class throw, if
any?


More information about the Tutor mailing list