函数特点

#def定义的非匿名函数,不会被立即回收
'''
def foo():
print("in the foo")
bar() #foo调用的时候,还未被被定义,所以报错

foo()
'''
def bar():
print("in the bar")

def foo():
print("in the foo")
bar() #已经被定义,所以不报错
foo()

#匿名函数,内存立即回收
calc = lambda x:x*3
calc(3) #等于9
posted @ 2018-05-23 15:39  无所住心  阅读(160)  评论(0编辑  收藏  举报