Output of 'ldd' to dictionary
This kind of parsing by pattern matching is much better done using a regular expression.

import re

libraries = {}
for line in ldd_out.splitlines():
    match = re.match(r'\t(.*) =&gt; (.*) \(0x', line)
    if match:
        libraries[match.group(1)] = match.group(2)