[Tutor] A class that instantiates conditionally ?
alan.gauld at btinternet.com
Tue Mar 1 18:50:18 CET 2011
"Hugo Arts" <hugo.yoshi at gmail.com> wrote
> Side question: Any reason why you'd raise the exception from __new__
> rather than __init__? If you want to return None, then yeah I can
> why you'd have to use __new__, but would there be any reason you
> or shouldn't simply raise an exception from __init__?
Because by the time you get to init you have already created
the instance. If you really want to avoid creating an instance it
needs to be in new.
More information about the Tutor