A Mountain of Perl Books + Python Advocacy

Ben Wolfson rumjuggler at cryptarchy.org
Tue May 9 18:07:28 EDT 2000


On Tue, 09 May 2000 16:52:28 GMT, tsummerfelt1 at myspleenhome.com (tony
summerfelt) wrote:

>On 08 May 2000 19:11:22 -0400, David Bolen wrote:
>
>> although perhaps doing so is not always of benefit for long
>> term maintainability and manageability.
>
>this is a regular argument against perl programming. personally i think the
>point is moot, if you can program in perl, you can read your code. i can
>still ready all the uncommented c code i wrote ten years ago :)
>
>>      lastline = None
>> 
>>      while 1:
>> 	 curline = input.readline()
>> 	 if not curline: break
>> 
>> 	 if curline != lastline:
>> 	     uniq.append(curline)
>> 	     lastline = curline
>
>
>correct me if i'm wrong, but a duplicate of the last line is what's checked?
>
>the code i posted (typos and all) the duplicate items could have been
>anyhere in the file:

import sys
lines = open(sys.argv[1]).readlines()
out = open(sys.argv[2], 'w')
uniqlines = []
lines.sort()
for line in lines:
   if line not in uniqlines:
      uniqlines.append(line)
      out.write(line)
out.close()

-- 
Barnabas T. Rumjuggler

NEW Epistemology Strips!  Dogs don't know they don't know it's not
bacon!
 -- Ranjit Bhatnagar



More information about the Python-list mailing list