728x90
반응형
728x170
import copy
class Animal:
def __init__(self, species, legCount, color):
self.species = species
self.legCount = legCount
self.color = color
harry = Animal("hippogriff", 6, "pink" )
carrie = Animal("chimera" , 4, "green polka dots")
billy = Animal("bogill" , 0, "paisley" )
list1 = [harry, carrie, billy]
list2 = copy.copy(list1)
list1[0].species = "ghoul"
print(list1[0].species)
print(list2[0].species)
"""
ghoul
ghoul
"""
728x90
반응형
그리드형(광고전용)
'Python > copy' 카테고리의 다른 글
[PYTHON/COPY] copy 함수 : 리스트 객체 본사본 만들기 (SHALLOW COPY) (0) | 2017.12.12 |
---|---|
[PYTHON/COPY] deepcopy 함수 : 리스트 객체 복사본 만들기 (DEEP COPY) (0) | 2017.10.03 |
[PYTHON/COPY] copy 함수 : 객체 복사본 만들기 (SHALLOW COPY) (0) | 2017.10.03 |
댓글을 달아 주세요