1def createInstance():
2 # Do what ever you want to determine if instance can be created
3 return True
4
5class CustomizeInstance(object):
6 def __new__(cls, a, b):
7 if not createInstance():
8 raise RuntimeError, "Count not create instance"
9 instance = super(CustomizeInstance, cls).__new__(cls, a, b)
10 instance.a = a
11 return instance
12
13 def __init__(self, a, b):
14 pass