what to do when instance of class fails to initialize ?
Fredrik Lundh
fredrik at pythonware.com
Wed Aug 20 04:41:06 EDT 2003
Tom Van den Brandt wrote:
> If I have an __init__ for a class and the initialisation can't go through
> (example: missing or wrong arguments), how do I return an error to the
> caller (from main() function)? When I do a return statement in the
> __init__ it says __init__ should return None... I can stop the flow with
> raise 'BlahBlah'. But then the program exits.
>
> What is the nice way to do this ?
catch the exception:
http://www.python.org/doc/current/tut/node10.html:
http://www.python.org/doc/current/ref/try.html
</F>
<!-- (the eff-bot guide to) the python standard library (redux):
http://effbot.org/zone/librarybook-index.htm
-->
More information about the Python-list
mailing list