Cancel instance create

Fuzzyman fuzzyman at gmail.com
Wed Sep 10 00:59:35 CEST 2008


On Sep 6, 1:23 pm, "Diez B. Roggisch" <de... at nospam.web.de> wrote:
> Mohamed Yousef schrieb:
>
> > ðWhat about no Constructor , and a custom instancing function that can
> > return either None or the instance wanted
>
> That doesn't solve the underlying problem - the instance is created.
> Just because it wasn't *returned*, doesn't mean it isn't there.
>
> Diez


def __new__(cls, *args, **kwargs):
    if some_condition:
        return None
    return object.__new__(cls)

Michael Foord
--
http://www.ironpythoninaction.com/



More information about the Python-list mailing list