can a class intantiate itself to None?

Timothy Grant tjg at
Fri Mar 16 20:22:11 CET 2001

I'd like to create a class that can instantiate itself to None
when instantiation fails...

class foo:
	def __init__(self, bar):
		if type(bar) == StringType: = 'This is a String'

x = foo('a')

y = foo(1)  # In this instance I would like y to be None

So, can it be done, or do I need to raise an exception, catch
it and then set y to None?

Stand Fast,

Timothy Grant                         tjg at
Red Hat Certified Engineer  
Avalon Technology Group, Inc.         <><       (503) 246-3630
>>>>>>>>>>>>>Linux, because rebooting is *NOT* normal<<<<<<<<<
>>>>This machine was last rebooted:  58 days 23:33 hours ago<<

More information about the Python-list mailing list