Answers for "how to decide whether or not we want to create instance in python"

0

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
Posted by: Guest on June-30-2021

Code answers related to "how to decide whether or not we want to create instance in python"

Python Answers by Framework

Browse Popular Code Answers by Language