python - How can I call a function defined in another function? -


Today I came to know that I can not find a way to call the function within any other function. Unless I explicitly return it to the main function or use the closure structure. But I am thinking that there is another way to call him. Or it will not be so wired, Python allows me to define functions inside the function, but I do not allow them to use them in a simple way!

My code is such, and I

  def a (): def b (): print 'b' def c (): calling 'print' c For example, call b (), c (), d (). 'Def D (): Print' D 'print' A '& gt; & Gt; & Gt; One () A & gt; & Gt; & Gt; AB Properties: There is no attribute in 'Function' object 'B' & gt; & Gt; & Gt; Eb () attribute: 'object' does not have any attribute 'b'    

Can not call those functions from outside the scope of the a they are limited to the scope of a

You can think of these tasks in the same way As you think about other local names in the function. For example: def foo (): bar = 42

As soon as you can not reference your local tasks outside the defined radius, you can not mention it bar foo () . Outside the scope of

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -