Monty @ The Python Coding Place @thepythoncodingplace.com · Mar 7

This is called a closure. An inner function also has access to variables defined in the enclosing scope, the one defined by the outer function So `print_` works as before and has access to the list `data`, which you can access, albeit with some difficulty (that's a good thing!)

0 likes 1 replies

?

Replies

Monty @ The Python Coding Place · Mar 7

We'll see better ways of accessing this common data later in this series. Also, note that there are other ways of achieving this type of behaviour. Creating a class would work and would be more readable, but I'm using this example to demonstrate and explain closures!