摘要: 今天看了下python的一些基本语法,首先给大家举个列子吧对于函数__call__,其首先需创建一个对象,然后通过此对象来调用call函数,如下api=API()api()而对于@staticmethod和@classmethod,两者之间的最大区别在在于被两个参数装饰的函数,是否需要传递隐式的传递类名,如上如果把factory函数的装饰器换成static的,则其参数cls需要删之。 阅读全文
posted @ 2013-05-26 22:57 SA高处不胜寒 阅读(464) 评论(0) 推荐(0) 编辑
摘要: class base(object):def help1(self,object1, spacing,collapse=1):"""Print method and doc string.Takes module, class, list, dictionary, or string."""typeList = (BuiltinFunctionType, BuiltinMethodType, FunctionType, MethodType, ClassType)methodList = [method for method in d 阅读全文
posted @ 2013-05-26 16:26 SA高处不胜寒 阅读(286) 评论(0) 推荐(0) 编辑
摘要: 在跑puppet的时候出现了这个问题root@ubuntu:/var/lib/puppet# puppet agent -tverr: Could not retrieve catalog from remote server: Connection refused - connect(2)warning: Not using cache on failed catalogerr: Could not retrieve catalog; skipping run一查资料原来是防火墙的问题 果断关之root@stgman-desktop:~# sudo ufw disable防火墙在系统启动时自 阅读全文
posted @ 2013-05-08 20:05 SA高处不胜寒 阅读(1867) 评论(0) 推荐(0) 编辑
摘要: Here's an example of how to do this:classMyDec(object):def __init__(self,flag):self.flag = flag def __call__(self, original_func): decorator_self =selfdef wrappee(*args,**kwargs):print'in decorator before wrapee with flag ',decorator_self.flag original_func(*args,**kwargs)print'... 阅读全文
posted @ 2013-05-05 11:17 SA高处不胜寒 阅读(259) 评论(0) 推荐(0) 编辑
摘要: http://www.cnblogs.com/yuxc/archive/2012/11/04/2753391.html 阅读全文
posted @ 2013-05-05 10:39 SA高处不胜寒 阅读(116) 评论(0) 推荐(0) 编辑
摘要: http://bbs.chinaunix.net/thread-2310556-1-1.html 阅读全文
posted @ 2013-04-14 16:04 SA高处不胜寒 阅读(177) 评论(0) 推荐(0) 编辑
摘要: 普通的方法,第一个参数需要是self,它表示一个具体的实例本身。如果用了staticmethod,那么就可以无视这个self,而将这个方法当成一个普通的函数使用。而对于classmethod,它的第一个参数不是self,是cls,它表示这个类本身。>>> class A(object): def foo1(self): print "Hello",self @staticmethod def foo2(): print "hello" @classmethod def foo3(cls): print "hello" 阅读全文
posted @ 2013-03-14 22:59 SA高处不胜寒 阅读(29578) 评论(0) 推荐(5) 编辑
摘要: <html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>sharejs.com 鼠标滑过按钮变色</title><style>body{background-color:151E23}#divIndexTop{width:100%;height:40px; position:absolute;}.btnTop{border-width:0px;width:80px 阅读全文
posted @ 2013-03-02 20:49 SA高处不胜寒 阅读(1160) 评论(0) 推荐(0) 编辑
摘要: <html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>点击转换颜色</title><style>body{background-color:151E23}#divIndexTop{width:100%;height:40px; position:absolute;}.btnTop{border-width:0px;width:80px;height:25px; m 阅读全文
posted @ 2013-03-02 20:26 SA高处不胜寒 阅读(490) 评论(0) 推荐(0) 编辑
摘要: # /etc/apt/sources.listdeb http://apt.puppetlabs.com lucid maindeb-src http://apt.puppetlabs.com lucid main 运行以下命令gpg --recv-key 4BD6EC30gpg --recv-key 4BD6EC30gpg -a --export 4BD6EC30 | sudo apt-key add - apt-get updateapt-cache policy puppet //查询源中存在的puppet的版本apt-cache policy puppetmaster //查询源中存在 阅读全文
posted @ 2013-02-25 15:23 SA高处不胜寒 阅读(419) 评论(0) 推荐(0) 编辑