I am trying to call a variable for use in another function. The variable is only in the other function and not declared as a global variable. Does anyone know how to call the other variable. The code below shows the ‘retval’ variable being used but it is declared in the other function.
def email_results():
if make.retval > 0:
os.system('python email_success.py')
else:
os.system('python email_failure.py')
if __name__ == '__main__': myObject = email_results()
Thanks
The function I declare it in is:
def make():
if os.path.exists(t):
command = "export ROOTDIR="+rootDir+"; "
command += "export PROJECT="+project+"; "
command += "export BUILD_DIR=$ROOTDIR/$PROJECT/basebuild; "
command += "export AD_EXEC_DIR=$BUILD_DIR/output_dev; "
command += "export BLDTARGET=MVArm9; "
command += "export PROFILE=release; "
command += "cd $ROOTDIR/$PROJECT; "
command += "make > "+logFileName+" 2>&1"
print "The command that I will be executing is:"
print command
#executing make command
retval = os.system(command)
print "retval=", retval
return retval
if __name__ == '__main__': myObject = make()
Your
make.retvalis (I’m guessing from your vague question) the result of another function,make, which for some reason doesn’t returnretval.Do this
Please find a good book on programming and read it. You’re having problems with fundamental concepts of programming, not Python specifically.