What is the benefit to define a function in a function in python?

后端 未结 3 844
名媛妹妹
名媛妹妹 2021-01-31 03:15

I encountered this piece of python code (pasted below) on effbot and I was wondering:

Why defining a function within a function?

import          


        
3条回答
  •  庸人自扰
    2021-01-31 03:48

    Why defining a function within a function?

    To keep it isolated. It's only used in this one place. Why define it more globally when it's used locally?

提交回复
热议问题