title: Grab password from a file by searching username and store that password in variable
body: <p>I have a password file containing different username and associated password for that user</p>
  
  <pre><code>$ cat /apps/test_lab/.passwd
      amon: abc@321
      bmon: dgf@869
      cmon: ascd@!!@657
  </code></pre>
  
  <p>What I am trying to do is get the password by searching in a file using the username and store it in a variable</p>
  
  <pre><code>text = "cmon"
  pswd_file = open("/apps/test_lab/.passwd", "r")
   for line in pswd_file:
       if re.match('(.+)'  +text+  '(.+)', line):
           print line
  </code></pre>
  
  <p>I am getting output as:</p>
  
  <pre><code>cmon: ascd@!!@657
  </code></pre>
  
  <p>While I want output like:</p>
  
  <pre><code>pswd_user="ascd@!!@657"
  </code></pre>
  
  <p>Can you help me with this? I am running as python 2.7.5.</p>