Closures in Object methods

Source: Internet
Author: User

This statement should not be accurate, even just on the closure itself this thing, can not clear the exact definition, on the example

def Inner (TMP):     return tmp def F (a):     return Inner (a)>>> f (1)def  F (a):    def  Inner (TMP):         return tmp     return Inner (a)>>> f (1)

Until I got selenium, I found a usage that I hadn't seen before (examples don't unittest write, like, for example).

def Run (self):     Print self.attr     class Test:     def __init__ (self,attr):        self.attr=attr    def Fun (self) :        run (self)        >>> Test (1). Fun ()1

Run is a fun call, fun is an instance method, run can also manipulate instance variable attr (self's role, how do not know);

#想起了实例方法的 from Types Impor methodtype., after writing the method definition and then binding

Closures in Object methods

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.