title: Python string comparison
body: <p>I have a python function that makes a subprocess call to a shell script that outputs 'true' or 'false'.  I'm storing the output from <code>subprocess.communicate()</code> and trying to do <code>return output == 'true'</code> but it returns <code>False</code> every time.  I'm not too familiar with python, but reading about string comparisons says you can compare strings using ==, !=, etc.</p>
  
  <p>Here's the code:</p>
  
  <pre><code>def verifydeployment(application):
      from subprocess import Popen, PIPE
      import socket, time
  
      # Loop until jboss is up.  After 90 seconds the script stops looping; this
      # causes twiddle to be unsuccessful and deployment is considered 'failed'.
      begin = time.time()
      while True:
          try:
              socket.create_connection(('localhost', 8080))
              break
          except socket.error, msg:
              if (time.time() - begin) &gt; 90:
                  break
              else:
                  continue
  
      time.sleep(15)  # sleep for 15 seconds to allow JMX to initialize
  
      twiddle = os.path.join(JBOSS_DIR, 'bin', 'twiddle.sh')
      url = 'file:' + os.path.join(JBOSS_DIR, 'server', 'default', 'deploy', os.path.basename(application))
  
      p = Popen([twiddle, 'invoke', 'jboss.system:service=MainDeployer', 'isDeployed', url], stdout=PIPE)
      isdeployed = p.communicate()[0]
  
      print type(isdeployed)
      print type('true')
      print isdeployed
      return isdeployed == 'true'
  </code></pre>
  
  <p>The output is:</p>
  
  <pre><code>&lt;type 'str'&gt; # type(isdeployed)
  &lt;type 'str'&gt; # type('true')
  true         # isdeployed
  </code></pre>
  
  <p>but <code>False</code> is always returned.  I also tried <code>return str(isdeployed) == 'true'</code>.</p>