2013 年文章归档
共 7 篇文章
Mixin and Trait
对于Mixin(混合)、Trait(特性)这两个面向对象特性,总是让人觉得说不清道不明的感觉,其实众多设计语言里,这里面的一些概念也是相互参杂的,并不是又那么一个严格的定义或界限说哪种一定是Mixin,或者哪种一定是Trait。这两种语言设施的提出,它的本质实际上都是解决代码复用的问题。下面我们局一些例子来说明。介于本人的认识有限,在此也只是说说自己的看法。 多继承 VS 单继承 The developers of the Java language were well-versed in C++ and other languages that include multiple inher…
pygraphviz 在windows 7/ python 2.7 下编译安装
pygraphviz 在windows 7/ python 2.7 下编译安装 1)首先安装graphviz 2)下载pygraphviz,并修改其根目录下的setup.py文件: library_path="C:\Program Files\Graphviz 2.28\lib\release\lib" include_path="C:\Program Files\Graphviz 2.28\include\graphviz" 注释掉runtime_library_dirs=library_dirs, 否则在build时出现 don't know how to set runtime lib…
(转)Method Resolution Order (MRO) in new style Python classes
Stack Overflow link: http://stackoverflow.com/questions/1848474/method-resolution-order-mro-in-new-style-python-classes The crucial difference between resolution order for legacy vs new-style classes comes when the same ancestor class occurs more than once in the "naive", depth-first approach -- e.…
2013-09-20 22:08 · Python
python实现的单子模式(附解释)
一、通过metaclass来实现 class Singleton(type): def __init__(self, name, bases, dct): super(Singleton, self).__init__(name, bases, dct) self.instance = None def __call__(self,*args,**kw): if self.instance is None: self.instance = super(Singleton, self).__call__(*args, **kw) return self.instance class A(obj…
2013-07-13 21:06 · Python
Wing IDE 4.1 破解方法
Wing IDE 4.1版本破解方法: 1、去官网下载最新版http://wingware.com/downloads/wingide ,我下载到的是4.1.6-1 2、安装之前,修改系统时间到一个月以前。 3、安装Wing IDE。 4、安装完成后获取试用版的许可,完成后关闭。 5、下载破解文件 ,解压后把abstract.pyo放到安装目录/bin/2.5/src/process/下。 6、把系统时间修改回来,重启Wing IDE即可。 PS:方法亲测可用,本人电脑win7 sp1. 推荐使用正版软件~ 【转】 http://www.ilovn.com/topic/wing-ide-4-…
2013-04-25 14:23 · Python
【转】探索Python下的property, classmethod, staticmethod的实现
转:http://marlonyao.iteye.com/blog/679425 Python有几个内置方法poperty, classmethod, staticmethod,其中property用来将方法变成属性,而classmethod将一个类的函数变成类方法,staticmethod将类的一个函数变成静态方法。它们是如何使用的,我这里就不讲了,只讲它们可能是怎样实现的。之所以说“可能”,是因为我并不确定,我对Python也只是初学,并且这里讲的可能也只是其中一种实现方式而已。 在讲实现之前我需要稍微介绍一下Python中的Descriptor,Descriptor提供了一种强大的机制…
2013-04-08 21:22 · Python
Pop3编码
http://blog.csdn.net/wangdetian168/archive/2007/02/06/1503525.aspx From RFC 2047: encoded-word = "=?" charset "?" encoding "?" encoded-text "?=" If you have text in that form, it is encoded. The encoding can be B (Base64) or Q (quoted-printable) MIME邮件系统的格式 http://www.codeproject.com/Articles/15611…
2013-04-01 15:49 · C#