On 2015-10-14 11:29, Danny Yoo wrote:
######################
def make_ask(f, l, p):
    d = {'Enter your first name: ' : f,
           'Enter your last name: ' : l,
           'Your mobile phone #: ' : p}
    return d.get
######################


This is an example of a 'closure' is it not?


Yes, though I try not to use the word "closure" because it's a
technical distinction that isn't really that useful for beginners
because it focuses on the implementation details.  That is, when we
say the word "closure", we're emphasizing the fact that it's a
combination of code and the data that it needs to resolve the code's
free variables.

I've been pondering the above and am wondering why the use of
"...and the data that it needs to resolve the code's free variables."
rather than simply "...and the data needed by the code to do its job."
I think what I'm asking is what exactly is meant by 'free variables'
or put another way, what makes a variable 'free' or otherwise?

ak
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to