Cancel instance create

Fuzzyman fuzzyman at gmail.com
Tue Sep 9 18:59:35 EDT 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