Control class is called only once ::
method 1:
class A:
a = 1
def __new__(cls, *args, **kwargs):
if cls.num==1:
cls.num + 1 =
return super().__new__(cls)
print ( "has been called one of the")
def __init__(self):
pass
Method 2:
class C:
a = 1
def __init__(self):
if C.num != 1:
raise Exception
C.num + 1 =
Control class method is invoked only once:
method 1:
class MyExceptions(Exception):
pass
class B:
def __init__(self):
pass
def test00(self):
try:
self.value # instantiated using the instance attributes, the parameter to be given whether the result
raise MyExceptions ( 'has been called one of the')
except AttributeError:
self.value = 0
print(self.value)
Method 2:
class C:
num = 1 # class properties with modification
def test00(self):
if C.num != 1:
raise Exception
C.num + 1 =