Notice
Recent Posts
Recent Comments
Link
«   2025/02   »
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28
Archives
Today
Total
관리 메뉴

RUBY

중첩함수 본문

프로그래밍 언어/Python

중첩함수

ruby-jieun 2023. 1. 7. 23:33

 

 

중첩함수

 


 

 

중첩함수

  • 함수안에 또 다른 함수가 있는 형태이다.
def out_funtion():
    print('out_function called!!')

    def in_funtion():
        print('in_function called!!')

    in_funtion()

out_funtion()
out_function called!!
in_function called!!

 

  • 내부 함수를 함수 밖에서 호출할 수 없다.
def out_funtion():
    print('out_function called!!')

    def in_funtion():
        print('in_function called!!')

    in_funtion()

in_funtion()
NameError: name 'in_funtion' is not defined. Did you mean: 'out_funtion'?

'프로그래밍 언어 > Python' 카테고리의 다른 글

모듈  (0) 2023.01.07
lambda함수  (0) 2023.01.07
지역변수와 전역변수  (0) 2023.01.07
데이터 반환  (0) 2023.01.07
인수와 매개변수  (0) 2023.01.07
Comments