05 2013 档案
摘要:今天看了下python的一些基本语法,首先给大家举个列子吧对于函数__call__,其首先需创建一个对象,然后通过此对象来调用call函数,如下api=API()api()而对于@staticmethod和@classmethod,两者之间的最大区别在在于被两个参数装饰的函数,是否需要传递隐式的传递类名,如上如果把factory函数的装饰器换成static的,则其参数cls需要删之。
阅读全文
摘要: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
阅读全文
摘要:在跑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防火墙在系统启动时自
阅读全文
摘要: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'...
阅读全文
摘要:http://www.cnblogs.com/yuxc/archive/2012/11/04/2753391.html
阅读全文

浙公网安备 33010602011771号