
编程语言: Python
iteye_3653
这个作者很懒,什么都没留下…
展开
-
python 内存泄露的诊断
对于一个用 python 实现的,长期运行的后台服务进程来说,如果内存持续增长,那么很可能是有了“内存泄露”。最近在我的项目中,就出现了内存持续增长的情况,goolge 了一下,发现 [url=http://www.lshift.net/blog/2008/11/14/tracing-python-memory-leaks]Tracing Python memory leaks[/url] 讲...2010-11-29 20:07:08 · 362 阅读 · 0 评论 -
python学习: Python的迭代器
1、 什么是迭代器迭代器就是提供 next() 方法的对象2、 如何使用迭代器for v in it:python 的 for 语句可对迭代器进行处理,它自动调用迭代器的 next() 方法进行遍历,并在遇到 StopIteration 异常后终止循环3、 有哪些迭代器?list, dict, 文件对象,都属于迭代器4、 为自己的类增加...原创 2010-11-29 20:10:14 · 270 阅读 · 0 评论 -
python学习: Python的生成器
1、 什么是生成器生成器是执行一个带 yield 语句的函数所返回的对象[code="python"]def foo(): yield 1 yield 2 f = foo()[/code] 其中, type(foo) 是 function, 而 type(f) 是 generaotr2、 生成器同时是迭代器生成器对象,实现了 __iter...原创 2010-11-29 20:12:54 · 180 阅读 · 0 评论 -
python学习: Python的装饰器
1、 什么是装饰器装饰器是对函数的修饰,形式如下:[code="python"]@decorator(deco_args)def func(func_args): pass[/code] 它等价于[code="python"]func = decorator(func)[/code]调用 func() 相当于 decorator...原创 2010-11-29 20:15:45 · 206 阅读 · 0 评论 -
python学习: python中的descriptor
descriptor 用与类的属性descriptor 是一个类,需要提供 __set__, __get__, __del__ 三个方法的实现。如果一个类的属性是 descriptor,那么:该属性不会出现在该类实例化后的对象的__dict__中。也就是说,它部作为字典的一部分出现。访问该属性时,调用descriptor的__get__()方法设置该属性时,调用de...原创 2011-08-31 00:39:11 · 177 阅读 · 0 评论 -
lua学习: lua的table类型
1、 table 是 lua 中最重要的数据类型。2、 table 类似于 python 中的字典。3、 table 只能通过构造式来创建例1:[code="lua"]mytable = { a = 10, b = 11, c = 20, ddd = 30 }print(mytable["a"])[/code]注释: 1)、 table 中的每项要求...原创 2011-09-07 15:07:13 · 431 阅读 · 0 评论 -
安装python package到指定目录
通过源码安装一个python包的时候,可通过 --home 或 --prefix 指定安装目录 python setup.py install --prefix=~/local 参看 http://docs.python.org/install/index.html alternate installation ...原创 2011-10-25 21:04:47 · 962 阅读 · 0 评论