-4

!/usr/bin/env python

import sys import ToBuildOrNot

repoArray = ["MSS_sims","PCS_CCS"]

def main(argv): for repo in 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"

if name == 'main': main(sys.argv[1:])

Jørgen R
  • 10,568
  • 7
  • 42
  • 59
  • 2
    `needsBuild` / `not needsBuild` is presumably sufficient (unless you're expecting more than two possible values) - but do you have a question? – Jon Clements Jun 26 '13 at 17:16
  • Yes my question is how do i scan the ToBuildOrNot.run('MSS_sims') for the true or false return value? – Barry Taylor Jun 26 '13 at 17:21
  • Why this question now - instead of elaborating on your [previous question](http://stackoverflow.com/questions/17323564/how-do-scan-a-script-for-return-values-from-a-upper-script-in-python) – Jon Clements Jun 26 '13 at 17:23
  • 1
    What do you mean by "scan"? You've stored the result in `needsBuild`. You can then use `if needsBuild:` or `if not needsBuild:` like you would for any other if block – recursive Jun 26 '13 at 17:23

1 Answers1

0

Use == for equality check not is, is is used for identity check.

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

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

Community
  • 1
  • 1
Ashwini Chaudhary
  • 244,495
  • 58
  • 464
  • 504
  • Additionally, it's better to raise an exception for an error, probably, instead of returning `True`, `False`, or "something else". – Wooble Jun 26 '13 at 17:28