関数から戻り値 True|False を取得できません。私は何を間違っていますか?
スクリプトは大まかにそのように見えます。
class getLogs:
IAM=getpass.getuser()
SRC_LOG_DIR='/server/log/session/'
DST_LOG_DIR="/home/${IAM}/LOGS/"
def __init__(self):
parser = argparse.ArgumentParser()
parser.add_argument("-S","--sessId", type=int, help="The SessionId of the logs to retreive for.")
args = parser.parse_args()
if not args.sessId:
args.sessId = 'ns'
os.system('clear')
print ('\tNo sessid was set.')
print ('\tTip: you can see what options you have by running "{} -h"'.format(__file__))
self.getSessID(args.sessId)
if self.getSessID:
print('\tI will get the logfiles for session ID "{}".'.format(self.sessId))
#Do something else
def getSessID(self, sessId):
if sessId == 'ns':
menu='on'
while menu=='on':
sys.stdout.write("\tPlease give me the sessionid of the logging :")
sessId = raw_input()
test = re.match("^[0-9]{5,7}$",sessId)
if test:
menu='off'
if not test:
print('\tError:\n\tSessionID should contain only numbers')
print('\tor sessID was not defined.')
print('\tor sessID length must be 5 to 7 characters')
self.sessId = sessId
return True
そして、これprint self.getSessID
とif self.getSessID
コンストラクター関数から得られるのはこれです<bound method getLogs.getSessID of <__main__.getLogs instance at 0x7f5aa28e1518>>
関数の戻り値から値を取得する方法がわかりません。誰か助けてくれませんか?