Prakash Bhattarai Prakash Bhattarai - 1 month ago 7
Python Question

What is the specific name of this output?

I have made a function named 'function' as below.

>>> def function():
return 'hello world'

>>> function
<function function at 0x7fac99db3048> #this is the output


What is this output exactly? It's specific name? And it's significance?
I know it gives info about memory location. But I need more information about this output.

Do the higher-order function return similar data while they are returning function?

Answer

In python function is an object and thus when you call function it returns you the memory address. The higher-order functions behave the same way. However there some differences:

a = def():
    print("Hello, World!")

b = def():
    return a

>>> a
<function a at 0x7f8bd15ce668>
>>> b
<function b at 0x7f8bd15ce6e0>

c = b

>>>c
<function b at 0x7f8bd15ce6e0>

c = b()
<function a at 0x7f8bd15ce668>

Note what the function c returns in different situations.