Misuse of list comprehensions?
cokofreedom at gmail.com
cokofreedom at gmail.com
Wed May 21 08:47:12 EDT 2008
''.join(seen.add(c) or c for c in s if c not in seen)
>From what I can understand...
.join will be a String of unique 'c' values.
'seen.add(c) or c' will always point to the second statement 'c'
because seen.add(c) returns None.
'if c not in seen' will ensure 'c' being added to both the .join and
seen is unique.
That is really clever! I like it :) (but does require a bit of
knowledge about .add return None and the affect that has on the ..
or .. statement)
More information about the Python-list
mailing list