What are the advantages of closures over pseudo-closures?
I want to follow up on a question I asked yesterday. One of the answers I got gave this link, and the first answer there brings up what I'm going to ask about. https://stackoverflow.com/questions/4020419/why-arent-JUMP_LINK__&&__python__&&__JUMP_LINK-nested-functions-called-closures The poster explains what a closure is by comparing two versions of a function. 1.) def make_printer(msg): def printer(): print(msg) return printer 2.) def make_printer(msg): def printer(msg=msg): print(msg) return printer The first function is a true closure, because the inner function, called from outside later, will try to access a value that will be gone by then - or would be, if it wasn't for printer.__closure__. The second version passes the value as a default-argument so that the function won't have to go for nonlocals. Function-wise they be the same. But if that's the case, what is the advantage of a genuine closure?