Nested Function in Python -


What can we gain with the Python code in this way:

  Class some_class ( 

I'm doing this with an open-in-source project, doing some useful work inside the nested function, but doing nothing except calling it (actual code Can be found.) Why can anyone put this code like this? To write code inside the nested function rather than the external, normal function, Whether there is a profit or side effect? ​​

Generally you make it Def make_adder (x): def add (y): return x + y return add plus5 = make_adder (5) print (plus 5 (12)) # prints 17 < / Code>

You can use the variable from the closing function (in this case, the local variable x ). If you are not reaching any variable from the attached frequency, They are actually doing just simple tasks with a different radius.


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -