Roughly. Low level stuff.
Anytime a function return a variable.
It is put on the stack.
Function closes.
Then stack item is assign to variable.
python bytecode.
Anytime a function return a variable.
It is put on the stack.
Function closes.
Then stack item is assign to variable.
python bytecode.
import os import dis def qassam(): filename = "/root/Downloads/scapy.txt" return filename def fileex(): filename = qassam() if os.path.isfile(filename): print("is there") else: print("else ... ") dis.dis(fileex)
Output: 10 0 LOAD_GLOBAL 0 (qassam)
2 CALL_FUNCTION 0
4 STORE_FAST 0 (filename)
11 6 LOAD_GLOBAL 1 (os)
8 LOAD_ATTR 2 (path)
10 LOAD_METHOD 3 (isfile)
12 LOAD_FAST 0 (filename)
14 CALL_METHOD 1
16 POP_JUMP_IF_FALSE 28
12 18 LOAD_GLOBAL 4 (print)
20 LOAD_CONST 1 ('is there')
22 CALL_FUNCTION 1
24 POP_TOP
26 JUMP_FORWARD 8 (to 36)
14 >> 28 LOAD_GLOBAL 4 (print)
30 LOAD_CONST 2 ('else ... ')
32 CALL_FUNCTION 1
34 POP_TOP
>> 36 LOAD_CONST 0 (None)
38 RETURN_VALUE
99 percent of computer problems exists between chair and keyboard.