Can __init__ not return an object?
Arnaud Delobelle
arnodel at googlemail.com
Sun Apr 22 08:12:58 EDT 2007
On Apr 22, 3:36 am, "Steven W. Orr" <ste... at syslang.net> wrote:
> When I go to create an object I want to be able to decide whether the
> object is valid or not in __init__, and if not, I want the constructor to
> return something other than an object, (like maybe None).
[...]
__init__ doesn't create an instance, it initializes it, i.e. does
things like settings some attributes, etc. The method that creates
instances is called __new__ (see http://docs.python.org/ref/customization.html).
--
Arnaud
More information about the Python-list
mailing list