title: Convert Unicode Strings to Python List
body: <p>I have this </p>
  
  <pre><code>x = "BA ( Socialogy)", "DAE ( Civil)", "MA ( Internation Relation", "BS'c"
  print x
  &lt;type 'unicode'&gt;
  </code></pre>
  
  <p>I wanted to convert it into python list like this </p>
  
  <pre><code>['BA (Socialogy)', 'DAE (Civil)','MA (Internation Relation)', 'BSc']
  </code></pre>
  
  <p>Note that last index of <strong>x</strong> has "BS'c" , quotes in between how to handle this thing.</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>What actually I am trying to do is to get all user's degrees titles from database and combine in one list.</p>
  
  <pre><code>SELECT 
  string_agg(distinct(E'\"'||title||E'\"'), ', ') as degree_titles, 
  FROM education
  WHERE user_id = 5
  GROUP BY r.resume_id;
  </code></pre>
  
  <p>on python Script.</p>
  
  <pre><code>    try:
          c = connection.cursor()
          c.execute(sql_query)
      except Exception as e:
          print e
      else:
          rows = c.fetchall()
          for row in rows:
              print row[2]
              print type(row[2])
  </code></pre>
  
  <p>it outputs </p>
  
  <pre><code>"BA ( Socialogy)", "DAE ( Civil)", "MA ( Internation Relation", "BS'c"
  &lt;type 'unicode'&gt;
  </code></pre>
  
  <p>More if I update my query to this then i get this.</p>
  
  <pre><code>   SELECT 
      string_agg(distinct(E'\''||title||E'\''), ', ') as degree_titles, 
      FROM education
      WHERE user_id = 5
      GROUP BY r.resume_id;
  </code></pre>
  
  <p>Then i will get this</p>
  
  <pre><code>'BA ( Socialogy)', 'DAE ( Civil)', 'MA ( Internation Relation', 'BS'c'
  </code></pre>
  
  <p>Then i use this code to convert it into list</p>
  
  <pre><code>import ast
  x = ast.literal_eval('[' + str(row[2]) + ']')
  </code></pre>
  
  <p>and it gives SyntaxError: invalid syntax on last value of <code>'BS'c'</code></p>