중첩 함수 (Nested function) 함수 내부에 정의된 함수 중첩 함수는 해당 함수가 정의된 함수 내에서 호출 및 변환 가능 중첩 함수는 함수 밖에서는 호출 불가 함수 안에 선언된 변수는 함수 안에서만 사용 가능한 원리와 동일(로컬 변수) def outer_func(): print("outer_function") # nested function 정의 def inner_func(): return "inner_function" print(inner_func()) outer_func() output outer_function inner_function 중첩 함수를 정의된 함수 밖에서 따로 호출할 수 없다. inner_func() output NameError: name 'inner_func' is no..
Nested Function / First-class Function / Closure Function
중첩 함수 (Nested function) 함수 내부에 정의된 함수 중첩 함수는 해당 함수가 정의된 함수 내에서 호출 및 변환 가능 중첩 함수는 함수 밖에서는 호출 불가 함수 안에 선언된 변수는 함수 안에서만 사용 가능한 원리와 동일(로컬 변수) def outer_func(): print("outer_function") # nested function 정의 def inner_func(): return "inner_function" print(inner_func()) outer_func() output outer_function inner_function 중첩 함수를 정의된 함수 밖에서 따로 호출할 수 없다. inner_func() output NameError: name 'inner_func' is no..
2022.04.14