function in python

*args, **kwargs

filter(None,['','Simon','Danny'])

def f1(x):
    if x>5:
        return True
    else:
        return False

filter

seq=range(0,10)
filter(f1,seq)

 

closure: namespace

def foo():
    x=1
    def bar():
         print (x)
    bar()

sort with inline function lambda

x=['ab','aab','czq']
x.sort(key=lambda x: x[1])

x
['aab','ab','czq']

 

 

posted on 2012-08-24 20:33  grep  阅读(202)  评论(0编辑  收藏  举报