I have a function that produces another function.
def make_func(greeting):
def func(name):
return greeting + " " + name
return func
>>> say_hello = make_func("Hello")
>>> say_hello("there")
"Hello there"
Elsewhere in the script, I have access to say_hello
, but I have no idea what the greeting in that function actually is. I'd like to find out.
name
, of course, isn't possible to get because it's specified when the function is called. But greeting is static
, because it's defined outside of the function.
Is there some attribute of say_hello
I can examine to get the original "Hello"
?