#!/usr/bin/env python# -*- coding: utf-8 -*-## functional.py# def foo(x,y,* args): sum = x + y for n in args: sum += n return sum#apply, filter, map, reducedef main(): print foo(1,2,3,4) print apply(foo,[1,2,3,4,5]) #apply是用于调用一个函数,函数本身也作为参数 #filter(func,seq),用函数判断序列中的元素是否合条件,为True,则选中,返回符合条件的li... Read More
posted @ 2013-04-25 02:23 庚武 Views(245) Comments(0) Diggs(0) Edit
#!/usr/bin/env python# -*- coding: utf-8 -*-## static_method.py# # Copyright 2013 xx <xx@ubuntu># class foo(): def __init__(self): print 'this is init' @staticmethod #声明静态方法 def bar(): print 'this is foo.bar()'def decorator1(func): def wrap1(): print 'this is wrap 1 begin&# Read More
posted @ 2013-04-25 01:48 庚武 Views(204) Comments(0) Diggs(0) Edit