摘要:
subprocess是python在2.4引入的模块, 主要用来替代下面几个模块和方法:os.systemos.spawn*os.popen*popen2.*commands.*可以参考PEP324:http://legacy.python.org/dev/peps/pep-0324/这是一个用来调用外部命令的模块, 替代了一些旧的模块, 提供了更加友好统一的接口.三个封装方法使用下面三个方法的时候, 注意两个问题: 1. shell=True或False, 两种解析方式是不同的 2. 注意PIPE的使用, 可能导致卡死subprocess.call 运行命令, 等待完成, 并返回return 阅读全文
随笔档案-2014年03月
Python tricks(7) -- new-style class的__slots__属性
2014-03-21 22:37 by 会被淹死的鱼, 590 阅读, 收藏,
摘要:
__slots__是在python 2.2开始引入的一个新特性, 我们来看一下官方给出的解释.This class variable can be assigned a string, iterable, or sequence of strings with variable names used by instances. If defined in a new-style class,__slots__reserves space for the declared variables and prevents the automatic creation of__dict__and__w 阅读全文