#python #anaconda #jupyter-notebook #visual-code #html #css #javascript #http

제목python default argument values2019-04-08 21:19
작성자

python.org 의 more about defining functions 쳅터에서 default argument values라는 것을 보게되었습니다.


Important warning: The default value is evaluated only once. This makes a difference when the default is a mutable object such as a list, dictionary, or instances of most classes. 


이런 문구를 보고 어떤것을 말하는것인지 실행해보니mb-file.php?path=2019%2F04%2F08%2FF192_190408_001.PNGmb-file.php?path=2019%2F04%2F08%2FF193_190408_002.PNG

mb-file.php?path=2019%2F04%2F08%2FF194_190408_003.PNG
와 같이

int 와 string 에 대해서는 각각에 대해 따로 초기화되고

list 에 대해서는 호출할때마다 list가 공유됨을 알 수 있었습니다.


int, string 과 list 간의 어떤 차이 때문에 이런 결과가 나오는건가요?

댓글