Question
Is it possible to return a value from the __init__()
method in a class?
Answer
The __init__()
method should either have no return statement at all (the most common and preferred usage) or it may have a return statement that returns the value None
. If the method attempts to return a value other than None
, Python will report the error “TypeError: __init__() should return None
”. If the method needs to report an error condition, then an exception should be raised.