2013-06-26 59 views
-4

的/ usr/bin中/ env的蟒

進口SYS 進口ToBuildOrNot如何在python中掃描返回值?

repoArray = [ 「MSS_sims」, 「PCS_CCS」]

DEF主(argv的): 用於repoArray回購:

needsBuild = ToBuildOrNot.ToBuildOrNot(repo) 

    if needsBuild == True: 
     print "\n",repo,"Needs To rebuilt\n" 
     print "---------------------------------------------------------------" 

    elif needsBuild == False: 
     print "\n", repo,"does NOT Need to be Rebuilt\n" 
     print "---------------------------------------------------------------" 

    else: 
     print "error" 

如果 == '主要': main(sys.argv [1:])

+2

'needsBuild' /'不needsBuild'據推測足夠了(除非你希望兩個以上的可能值) - 但是你有問題嗎? –

+0

是的我的問題是我如何掃描ToBuildOrNot.run('MSS_sims')的真或假返回值? –

+0

爲什麼現在這個問題 - 而不是闡述你的[上一個問題](http://stackoverflow.com/questions/17323564/how-do-scan-a-script-for-return-values-from-a-upper-腳本在蟒蛇) –

回答

0

使用==進行相等性檢查不是is,is用於身份檢查。

if needsBuild == True: 
    print "The MSS_sims Needs To rebuilt" 

elif needsBuild == False: 
    print "The MSS_sims does NOT Need to be Rebuilt" 

else: 
    print "error 

相關:Is there a difference between `==` and `is` in Python?

+0

此外,最好爲錯誤引發異常,而不是返回'True','False',或者是其他東西」。 – geoffspear