passing object to object
This question already has an answer here:
What you're encountering is a closure.
When you write part_string(my_indexes)
you're creating a new function, and upon calling it, you use the old variables you gave to part_string
together with the new variables given to function_instance
.
You may name the inner function whatever you want, and there is no convention. ( obj
is used in here but it can be pie
. There are no conventions for this except func
for function closures (decorators).
If you wish to pass two variables to the function, you may define two variables to the g(obj)
function:
def g(var1, var2):
...
Here's some more info regarding closures in python.
链接地址: http://www.djcxy.com/p/51112.html上一篇: python:绑定是如何工作的
下一篇: 将对象传递给对象