Sep-16-2018, 09:47 AM
Function variables are local to function. They cannot be shared.
options.
maybe have function return variable.
options.
maybe have function return variable.
import os def qassam(): filename = "/root/Downloads/scapy.txt" return filename def fileex(): filename = qassam() if os.path.isfile(filename): print("is there") else: print("else ... ") fileex()Make shared variables
import os class ShareVariables: filename = "" def qassam(): ShareVariables.filename = "/root/Downloads/scapy.txt" def fileex(): if os.path.isfile(ShareVariables.filename): print("is there") else: print("else ... ") qassum() fileex()My least favorite. Have global variable
import os filename = "" def qassam(): global filename filename = "/root/Downloads/scapy.txt" def fileex(): if os.path.isfile(filename): print("is there") else: print("else ... ") qassum() fileex()
99 percent of computer problems exists between chair and keyboard.