how to decide whether or not we want to create instance in python
def createInstance():
# Do what ever you want to determine if instance can be created
return True
class CustomizeInstance(object):
def __new__(cls, a, b):
if not createInstance():
raise RuntimeError, "Count not create instance"
instance = super(CustomizeInstance, cls).__new__(cls, a, b)
instance.a = a
return instance
def __init__(self, a, b):
pass