摘要: 为了深入研究变量的作用域,有必要先了解一下函数(function)和代码(code)对象。让我们先看一个例子:def f1(a,b): c = a+b return cdef f2(): print "ok"在IPython中运行之后,让我们查看函数f1()的一些属性:>>> ru... 阅读全文
posted @ 2015-12-22 16:08 高山流的不是水 阅读(245) 评论(0) 推荐(0) 编辑
摘要: site-packages/django/utils/functional.py 1 def new_method_proxy(func): 2 def inner(self, *args): 3 if self_wrapped is empty: 4 ... 阅读全文
posted @ 2015-12-02 18:49 高山流的不是水 阅读(437) 评论(0) 推荐(0) 编辑
摘要: 安装 storm : pip install storm目标:修改 Storm 源代码以支持自动重连文件:python安装目录/site-packages/storm/database.py在411行添加函数(可以不在这一行,只要是给class Connection添加函数就行):def _chec... 阅读全文
posted @ 2015-11-27 12:21 高山流的不是水 阅读(644) 评论(0) 推荐(0) 编辑
摘要: 最近做的事情是用mrjob写mapreduce程序,从mongo读取数据。我的做法很容易也很好懂,因为mrjob可以支持sys.stdin的读取,所以我考虑用一个python程序读mongo中的数据,然后同时让mrjob脚本接受输入,处理,输出。具体方式:readInMongoDB.py:#codi... 阅读全文
posted @ 2015-11-05 14:30 高山流的不是水 阅读(324) 评论(0) 推荐(0) 编辑
摘要: When using a mongoDB collection as input, add the arguments-jobconf mongo.input.uri=and-inputformat com.mongodb.hadoop.mapred.MongoInputFormatWhen usi... 阅读全文
posted @ 2015-11-04 15:35 高山流的不是水 阅读(247) 评论(0) 推荐(0) 编辑
摘要: 每个项目都应该有自己的虚拟环境,如何方便的操作呢?1. 安装 virtualenv2. 安装 virtualenvwrapper3. 创建目录用来存放虚拟环境mkdir $HOME/.virtualenvs5. 在~/.bashrc中添加行:export WORKON_HOME=$HOME/.vir... 阅读全文
posted @ 2015-11-03 15:45 高山流的不是水 阅读(260) 评论(0) 推荐(0) 编辑
摘要: class LazyImport: def __init__(self,module_name): self.module_name = module_name self.module = None def __getattr__(self,n... 阅读全文
posted @ 2015-10-06 13:30 高山流的不是水 阅读(172) 评论(0) 推荐(0) 编辑
摘要: #使用str.format()函数 #使用'{}'占位符 print('I\'m {},{}'.format('Hongten','Welcome to my space!')) >>> I'm Hongten,Welcome to my space! print('#' * 40) #... 阅读全文
posted @ 2015-10-06 13:21 高山流的不是水 阅读(173) 评论(0) 推荐(0) 编辑
摘要: Mac上的VimMac本身其实是预装了Vim的,但是目前的系统中都是Vim7.3版本的,而最新的Vim已经是7.4版了,因此为了能够使用最新版的vim,必须要对Mac中的vim要么升级,要么重装。在折腾过程中,遇到了一些问题,这里记录,以鉴后人。可选方案升级原生的Vim7.3这种方法貌似是最”干净”... 阅读全文
posted @ 2015-09-25 16:57 高山流的不是水 阅读(1796) 评论(0) 推荐(0) 编辑
摘要: 创建新分支:git branch branchName切换到新分支:git checkout branchName然后,上面两个命令也可以合成为一个命令:git checkout -b branchName合并分支: git checkout master git merge newbranch... 阅读全文
posted @ 2015-09-11 17:46 高山流的不是水 阅读(164) 评论(0) 推荐(0) 编辑