from os import popen import re f = popen('who', 'r') for eachLine in f.readlines(): print split('\s\s+|\t', eachLine.strip()) f.close()