"Destructor"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-source +syntaxhighlight))
 
(다른 사용자 한 명의 중간 판 하나는 보이지 않습니다)
3번째 줄: 3번째 줄:
==Python==
==Python==
[[category: Python]]
[[category: Python]]
<source lang='Python'>
<syntaxhighlight lang='Python'>
class Dog(object):
class Dog(object):
     def __init__(self):
     def __init__(self):
16번째 줄: 16번째 줄:
# constructing dog
# constructing dog
# destructing dog
# destructing dog
</source>
</syntaxhighlight>
<source lang='Python'>
<syntaxhighlight lang='Python'>
class Dog(object):
class Dog(object):
     def __del__(self):
     def __del__(self):
25번째 줄: 25번째 줄:
del mydog
del mydog
# destructing dog
# destructing dog
</source>
</syntaxhighlight>
<source lang='Python'>
<syntaxhighlight lang='Python'>
class Dog(object):
class Dog(object):
     def __del__(self):
     def __del__(self):
36번째 줄: 36번째 줄:
del ourdog
del ourdog
# destructing dog
# destructing dog
</source>
</syntaxhighlight>


==같이 보기==
==같이 보기==
*[[constructor]]
*[[constructor]]
*[[del]]
*[[소멸자]]
*[[소멸자]]

2020년 11월 2일 (월) 02:31 기준 최신판

destructor

1 Python[ | ]

class Dog(object):
    def __init__(self):
        print('constructing dog')
    def __del__(self):
        print('destructing dog')

def func():
    mydog = Dog()

func()
# constructing dog
# destructing dog
class Dog(object):
    def __del__(self):
        print('destructing dog')

mydog = Dog()
del mydog
# destructing dog
class Dog(object):
    def __del__(self):
        print('destructing dog')

mydog = Dog()
ourdog = mydog
del mydog
del ourdog
# destructing dog

2 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}