Is this a closure?

ssecorp circularfunc at gmail.com
Mon Sep 1 01:53:36 CEST 2008


A method on a class:

def printSelf(self):
        def printReviews():
            for review in self.reviews:
                review.printSelf()
        print "Idnbr: ", self.idnumber, "Reviews: ", printReviews()

I don't have to pass an argument to printReviews because everything
defined inside printSelf is aware of outer variables? Or is that
wrong? If it is right, is this what a closure means?

Because Python is lexically scoped right? Is lexical scope+closures =
organized dynamic scope kind of if you get my point?




More information about the Python-list mailing list