티스토리 뷰
# mutable immutable
def main():
# List is mutable
myList = [1, 2, 3]
print(hex(id(myList)), myList)
myList.append(4)
print(hex(id(myList)), myList)
# int is immutable
myInt = 3
print(hex(id(myInt)), myInt)
myInt += 1
print(hex(id(myInt)), myInt)
if __name__ == "__main__":
main()
[Output]
0x20fd3e84508 [1, 2, 3]
0x20fd3e84508 [1, 2, 3, 4]
0x55ce80b0 3
0x55ce80d0 4
'Ongoing > Mutable' 카테고리의 다른 글
mutable immutable [Python] function (0) | 2019.05.21 |
---|