Returning 'None' on Instantiation ?

Dave Haynes Dave.Haynes at
Fri Jun 1 15:28:11 CEST 2001

Is there a way to optionally return 'None' on instantiation? I'm
thinking of something like the following:

class myClass:
    def __init__(self, param):

        if <check param>:
            <initialise data members>
            <make self a 'None object'>

myParam = GetParam()
myObj = myClass(myParam)

if myObj:
    print 'Okay'
    print 'Couldn't make myObj from myParam'

 This is a fairly common state of affairs. If there's nothing specific
in Python to accomodate this, what methods are considered robust by
this NG?

                       Best Regards,


More information about the Python-list mailing list