导航

2015年12月17日

摘要: 目前我知道的有两种方法:1 定义的类继承dict类例如class A(dict): passa = A()a['name'] = 122 给自定义的类添加__setitem__() __getitem__()方法class A: def __init__(self, cfg={}): self.c... 阅读全文

posted @ 2015-12-17 18:02 网名还没想好 阅读(501) 评论(0) 推荐(1) 编辑

摘要: 列表按难度排序,常用的语言特征和技巧放在前面。1.1 分拆>>> a, b, c = 1, 2, 3>>> a, b, c(1, 2, 3)>>> a, b, c = [1, 2, 3]>>> a, b, c(1, 2, 3)>>> a, b, c = (2 * i + 1 for i in ran... 阅读全文

posted @ 2015-12-17 17:40 网名还没想好 阅读(218) 评论(0) 推荐(0) 编辑

摘要: # -*- coding: utf-8 -*-import loggingdef singleton(cls): instance = {} def _singleton(*args, **kw): if cls not in instance: in... 阅读全文

posted @ 2015-12-17 15:49 网名还没想好 阅读(799) 评论(0) 推荐(0) 编辑

摘要: from tornado import genfrom tornado.ioloop import IOLoop@gen.coroutinedef throw(a,b): try: a/b raise gen.Return('hello') except E... 阅读全文

posted @ 2015-12-17 11:09 网名还没想好 阅读(677) 评论(0) 推荐(0) 编辑