John Salerno a écrit :
I posted this code last night in response to another thread, and after I posted it I got to wondering if I had misused the list comprehension.
(snip)
def compress(s):
new = []
[new.append(c) for c in s if c not in new]
return ''.join(new)
As far as I'm concerned (and I'm a big fan of list-comps, generator expressions etc), this is definitively an abuse. And a waste of resources since it builds a useless list of 'None'.
-- http://mail.python.org/mailman/listinfo/python-list
