making a class return None from __init__

Rajarshi Guha rajarshi at
Fri Oct 4 22:09:31 CEST 2002

  I have a class which makes some basic error checks in the __init__
function. Ideally, if the parameters passed to the __init__ function fail
the checks I would like to return a None. But this does'nt seem to

class Graph:
	def __init__(self,v):
			return None

However when I test it out as:

g = Graph(v)
print g

(where v will fail) I always get <__main__.Graph instance at 0xXXXXXX>
Is there any way to make the constructor return a None object?


More information about the Python-list mailing list