#!/usr/bin/env python #example file # >sn: LASTNAME1 # >description: DESC BLAH BLAH ONE # >givenName: FIRSTNAME1 # >accountExpires: 2011/01/23 #global var r_file points to file to be read r_file = "file.txt" #open file for reading; str handle f_stream with open(r_file) as f_stream: entryList = f_stream.readlines(); #print list entries for l in entryList: l[1:].split(':')[0] print l #pooping print "total lines:", len(entryList) #close ref to f_stream f_stream.close()