OOP - how to abort an __init__ when the initialisation code fails ?

R.Wieser address at not.available
Mon Nov 4 13:59:06 EST 2019


Rob,

> Returning None will specifically NOT accomplish the thing you want; 
> nothing ever checks the return value of __init__.

I thought to have read that when you return a none from it the object itself 
would return a placeholder singleton.

> Raise an exception.

Yeah, that was what I was thinking too - up until the moment I realized that 
the than-needed "try" around creating the object would catch /all/ errors in 
there, and not just the "can't initialize" one ...   I might have 
misunderstood that though.

Regards,
Rudy Wieser




More information about the Python-list mailing list