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

R.Wieser address at not.available
Mon Nov 4 10:32:54 EST 2019


Hello all,

The whole question: How should I handle failed initialisation code inside 
the __init__ of an object ?

I've seen an example doing a plain "return" (of the value "none""), but have 
no idea if that is all it takes.

Also, I wonder what happens to the object itself.   Does it still exist and 
only gets actually destroyed at the next garbage-collection (because of a 
zero reference count), or is it directly discarded (without having called 
the __del__ method) ?

Regards,
Rudy Wieser




More information about the Python-list mailing list