title: Save stdout into variables in Python
body: <p>The properties file stores the information as Key and Values.
  Here Key is USER_NAME, PASSWORD, IP_ADD
  and Value is fenfnewl, fnaofna, ftp.internal.com</p>
  
  <p>I wrote python script to extract info using a regex and printed the output. The output looks like </p>
  
  <pre><code>USER_NAME = fenfnewl
  PASSWORD = fnaofna
  IP_ADD = ftp.internal.com
  </code></pre>
  
  <p>I have variables V_USER_NAME, V_PASSWORD, V_IP_ADD. I want these variables to get the values as follows</p>
  
  <pre><code>V_USER_NAME = fenfnewl
  V_PASSWORD = fnaofna
  V_IP_ADD = ftp.internal.com
  </code></pre>
  
  <p>The code that i wrote to get the output from properties file is as follows and it works fine. I just want to change the Keys from USER_NAME to V_USER_NAME in the output.</p>
  
  <pre><code> #!/usr/bin/env python
  
  import re # import the regular expressions module
  import sys
  import mysql.connector
  
  
  val = 'DEFAULT'
  print val
  
  
  
  REG_EXP={'DEFAULT':r"\bDEFAULT_(USER_NAME|PASSWORD|IP_ADD)\w*\b",
           'NOT_DEFAULT':r"\bNOT_DEFAULT_(USER_NAME|PASSWORD|IP_ADD)\w*\b"}
  filename = "/Users/DOCUMENTS/some.properties"
  
  if val != 'DEFAULT':
      pattern = re.compile(REG_EXP['NOT_DEFAULT'], re.IGNORECASE)
      with open(filename, "rt") as in_file:
          for line in in_file:
              if pattern.search(line) != None:
                  print(line)
  
  
  else:
      pattern = re.compile(REG_EXP['DEFAULT'], re.IGNORECASE)
      with open(filename, "rt") as in_file:
          for line in in_file:
              if pattern.search(line) != None:
                  print(line)
  </code></pre>
  
  <p>I am a beginner to python. Any help is much appreciated. Thanks in advance</p>