티스토리 뷰
Piece
Class [Python] allocator __new__ & initializer __init__ & finalizer __del__
More Code 2018. 6. 30. 08:18참고 :
Data model > Special method names > Basic customization
Understanding __new__ and __init__
class Class1:
def __new__(cls): # allocator
print('in __new__')
return super().__new__(cls)
def __init__(self): # initializer
print('in __init__')
super().__init__()
def __del__(self): # finalizer
print('in __del__')
def say(self, words: str):
print("say", words)
if __name__ == '__main__':
c1 = Class1()
c1.say('Hello')
'Piece' 카테고리의 다른 글
Python Script [SQL] sp_configure sp_execute_external_script (0) | 2018.06.30 |
---|---|
[SQL] Table Field Record (0) | 2018.06.30 |
[Python] Check Package Dependencies (0) | 2018.06.30 |
[C] struct Initialization (0) | 2018.06.25 |
[C] GetCurrentDirectory GetWindowsDirectory GetSystemDirectory (0) | 2018.06.25 |