摘要: 记录tornado文档中对自己有用的信息:A Tornado web application maps URLs or URL patterns to subclasses oftornado.web.RequestHandler. Those classes defineget()orpost()methods to handle HTTPGETorPOSTrequests to that URL.The request handler can access the object representing the current request withself.request.TheHTT 阅读全文
posted @ 2013-05-07 17:26 tangr206 阅读(332) 评论(0) 推荐(0) 编辑
摘要: 之前在讨论闭包的时候有提到: Python会按LEGB的顺序来搜索变量:要说明的是,这里的访问规则只对普通变量有效, 对象属性的规则与这无关(简单地说,访问一个对象的属性与此无关)。L. Local. 局部作用域,即函数中定义的变量(没有用global声明)E. Enclosing. 嵌套的父级函数的局部作用域,即包含此函数的上级函数的局部作用域,比如上面的示例中的labmda所访问的x就在其父级函数test的局部作用域里。通常也叫non-local作用域。G. Global(module). 在模块级别定义的全局变量(如果需要在函数内修改它,需要用global声明)B. Built-... 阅读全文
posted @ 2013-05-07 16:28 tangr206 阅读(1300) 评论(0) 推荐(0) 编辑
摘要: 区别Being educated under Java background, static method and class method are the same thing.But not so in Python, there is subtle difference:Sayfunction a()is defined inParentClass, whileSubClass extendsParentClassIf functiona()has@staticmethoddecorator,Sub.a()still refers to definition insideParentCl 阅读全文
posted @ 2013-05-07 13:03 tangr206 阅读(543) 评论(0) 推荐(0) 编辑