Newbie help with manipulating text files

William Dandreta wjdandreta at worldnet.att.net
Sat May 26 01:56:14 CEST 2001


Hi jk,

Here is a different way:

lines = file.readlines()

counter = 0
(headerlist,middlelist,footerlist)  = ([],[],[])
for line in lines:
  if line[:6] == 'middle':
    middlelist += line
    counter += 1
  elif: counter == 0: headerlist += line
  else: footerlist += line
middlelist.sort()
wholelist = headerlist + middlelist + footerlist

bill





More information about the Python-list mailing list