Is there a difference in the output depending on the function ()?

Asked 1 years ago, Updated 1 years ago, 94 views

>>> from platform import system, release
>>> print(system, release)
<function system at 0x00000126E1EC9280> <function release at 0x00000126E1EC93A0>
>>> print(system(), release()) 
Windows 10

I'm bringing up the information on the current system What is the exact reason for the difference in output depending on the function followed by () and not?

python python-3.x

2022-09-21 12:27

1 Answers

Python is a first-class object language.

def func(): return 1

When

func() is a function call, but func is a pointer to the function. The address of the function.

def process(f):
    return f()

def func(): return 1

print(process(func))

The above code outputs 1.

We put func as a process function and run it.


2022-09-21 12:27

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.