"Bruno Desthuilliers" <[EMAIL PROTECTED]> wrote in 
message news:[EMAIL PROTECTED]

>> 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'.

I agree with you. After being proud of myself for about 20 seconds, it 
suddenly seemed like an abuse rather than a clever way to do it in one line. 
:) It just looked wrong to have a list comp. without an assignment, etc.

Actually, though, I wasn't so much thinking of the waste of resources as I 
was that what was happening didn't seem to be explicit or evident enough. So 
despite the fact that the for loop with the nested if is the exact same 
code, it just seems more appropriate. 


--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to