Cancel instance create

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

On Sep 6, 1:23 pm, "Diez B. Roggisch" <de... at> 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

More information about the Python-list mailing list