Class returning None ?

George Marshall g.marshall at nospam.com
Mon Jan 26 03:43:42 EST 2004


Hi, I'm wondering, what's the best way to check for
success or failure on object initialization ?

This is my ugly workaround to do that :

class mytest:
	status=0
	def __init__ (self):
		status=1
	
_mytest =  mytest()

def mytest ():
     if everythingok():
         return _mytest()
     else:
         return None

def everythingok():
	return False

def main():
	a=mytest()
	if a==None:
		return 1

if __name__ == "__main__"
	main()


What's the python way to do that ?

Thanks.




More information about the Python-list mailing list