-
Notifications
You must be signed in to change notification settings - Fork 0
classtools.postint
sikvelsigma edited this page Aug 18, 2022
·
4 revisions
- class
PostInit
Inhereting from PostInit adds a call to __postinit__ method after __init__ call was completed
- metaclass
PostInitMeta
Inhereting from PostInitMeta is not advised
from pyuseful.classtools.postinit import PostInit
class Test(PostInit):
# postinit is called immediately after init
def __init__(self):
print("this prints on init")
self.a = 1
def __postinit__(self):
print("this prints after init is done")
print(self.a)
t = Test()