David wrote: > Martin Walsh wrote: >>> ... but, you don't need to use subprocess at all. How about (untested), >>> >>> # grep USE /tmp/comprookie2000/emerge_info.txt |head -n1|cut -d\" -f2 >>> infof = open('/tmp/comprookie2000/emerge_info.txt') >>> for line in infof: >>> if 'USE' in line: >>> USE = line.split('"')[1] >>> break >>> else: >>> USE = '' >>> infof.close() >>> > > Thanks Martin works perfect. So I understand correctly, line.split('"') > splits the list on " so [1] grabs after USE = " and up till [2] starts.
That's right, in other words it emulates the behavior of 'cut -d\" -f2'. Python having 0-based indexing, you use 1 instead of 2, etc. > Again thanks, I like the comments :) > -david > Welcome, glad it helped. Marty _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor