In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "what is the essence of Python function names". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let Xiaobian take you to learn "What is the essence of Python function names"!
Nature of Function Names
A function name is essentially the memory address of the function.
def wrapper():
pass
print(wrapper)
1. What is a quote?
When we define a=1, the system will open up a memory space to store 1, and then use the variable name a to store the memory address reference where 1 is located. The variable name is like a pointer in C language. You can understand the reference as an address. The address stored in a is the address where the value of 1 is located. A stores a reference to 1.
When we define a function in the code, the system allocates a memory space for storing the internal variables and function names of the function body. This wrapper is just a variable name that stores the address in the memory of the function. We can assign x = wrapper,y = wrapper. Such an operation is equivalent to assigning the address referenced in the wrapper to x, y, so that x and y point to the reference where the wrapper function is located. We can call the wrapper function x() and y(). The call is actually a function, and the x, y, wrapper variables store the address of the same function.
The function name holds the memory address of the function
def func():
print(1)
print(func)
#
Function names assigned to other variables
def func():
print(1)
x = func
y = func
x()
y()
A function name can be an element of a container class
#Python learning exchange QQ group: 778463939
def fun():
print(111)
def fun1():
print(222)
def fun2():
print(333)
l1 = [fun,fun1,fun2]
for i in l1:
i()
Function names can be used as arguments to other functions
The function name stores the address of the function in memory, f1 = f = f() Internal address-> f1()
def f():
print(123)
def fun(f):
f1 = f
f1()
fun(f)
Function names can be used as return values for other functions
def func():
print(123)
def fun(f):
return f
ret = fun(func)
ret() At this point, I believe that everyone has a deeper understanding of "what is the essence of Python function names", so let's actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.