I am using return value of function into another function, I want to do first I check if function return value ? if yes then only use return value I am able to do this but in my case function call two times reason also i know but how can I achieve it with function call for only one time
Actually I am new in programming please can anyone help me Thank you in advance
from loginAuth import *
class DisplayInfo:
def displayInfo(self):
# create object of loginAuth class
obj = LoginAuth()
if obj.check_password_and_userid():
userid, userrole = obj.check_password_and_userid()
print(userid,userrole)
obj = DisplayInfo()
obj.displayInfo()
here method: check_password_and_userid() is a function of class LoginAuth which return userid and userrole
output : 01 Admin
obj.check_password and userid() returns a tuple like (userid, user role) if it's true then you can just set data to a variable then play with the data.
from loginAuth import *
class DisplayInfo:
def displayInfo(self):
# create object of loginAuth class
obj = LoginAuth()
data = obj.check_password_and_userid()
if data:
userid, userrole = data
print(userid,userrole)
obj = DisplayInfo()
obj.displayInfo()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.