PS/Python

PS/Python

[Python] 다중 할당 과 passed by assignment

Python의 다중 할당 개념이 헷갈려서 정리하는 글 Python은 아래의 구문과 같이 동시에 여러 변수에 값을 할당하는 다중 할당을 지원한다. a, b = 1, 2 이렇게 동시에 a와 b에 값을 넣을 수 있다. 그런데 만약 동시에 같은 객체에 다중할당을 사용한다면 어떻게 될까? 다음과 같은 linked list 의 node class에서 다중할당을 한다고 해보자. # Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next # list1 : 1 -> 3 -> 5 # list2 : 2 -> 4 -> 6 list1, list1.next..

PS/Python

Python - defaultdict

https://docs.python.org/3.3/library/collections.html#defaultdict-objects 8.3. collections — Container datatypes — Python 3.3.7 documentation 8.3. collections — Container datatypes Source code: Lib/collections/__init__.py This module implements specialized container datatypes providing alternatives to Python’s general purpose built-in containers, dict, list, set, and tuple. namedtuple() fact docs..

램램
'PS/Python' 카테고리의 글 목록