2014年12月27日
摘要: 这里采用的是算法导论的划分方式: import random def partition(array, left, right): pivot = array[left] i = left #j left +1 -> right for j in range(left + 1, right + 1): if array[j] right ... 阅读全文
posted @ 2014-12-27 22:10 inevermore 阅读(264) 评论(0) 推荐(0) 编辑
摘要: 我们先看一个闭包的例子: from time import ctime def before_call(f): def wrapped(*args, **kargs): print 'before calling, now is %s' % ctime() return f(*args, **kargs) return wrapped d... 阅读全文
posted @ 2014-12-27 21:44 inevermore 阅读(466) 评论(0) 推荐(0) 编辑
摘要: 最近要使用python,研究下闭包特性。 看下列的代码: def counter(start_at = 0): count = [start_at] def incr(): count[0] += 1 return count[0] return incr if __name__ == '__main__': cou... 阅读全文
posted @ 2014-12-27 21:32 inevermore 阅读(197) 评论(0) 推荐(0) 编辑