How to access a function inside a function? Python

Posted by viddhart on Stack Overflow See other posts from Stack Overflow or by viddhart
Published on 2013-06-30T22:12:29Z Indexed on 2013/06/30 22:21 UTC
Read the original article Hit count: 215

Filed under:
|

I am wondering how I can access a function inside another function. I saw code like this:

>>> def make_adder(x):
      def adder(y):
        return x+y
      return adder
>>> a = make_adder(5)
>>> a(10)
15

So, is there another way to call the adder function? And my second question is why in the last line I call adder not adder(...)?

Good explanations are much appreciated.

© Stack Overflow or respective owner

Related posts about python

Related posts about function