A Mountain of Perl Books + Python Advocacy

Ben Wolfson rumjuggler at cryptarchy.org
Tue May 9 18:22:47 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:
>
>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:

This is even more fun:

import sys, operator
lines = open(sys.argv[1]).readlines()
def ifthenelse(condition, true, false):
   if condition:
      return true()
   return false()
map(lambda a, b, list=lines: ifthenelse(list.count(a)>1, lambda
b=b,list=list: operator.delitem(list,b), lambda a=a: a), lines,
range(len(lines)))
open(sys.argv[2],'w').writelines(lines)

but it's kind of pointless.

-- 
Barnabas T. Rumjuggler

There is only one place, and that place is time.
 -- Russell Hoban, _The Lion of Boaz-Jachin and Jachin-Boaz_



More information about the Python-list mailing list