Is there any advantage or disadvantage to using sets over list comps to ensure a list of unique entries?

rusi rustompmody at gmail.com
Mon Jun 20 23:59:56 EDT 2011


On Jun 21, 12:43 am, deathweaselx86 <deathwea... at gmail.com> wrote:
> Howdy guys, I am new.
>
> I've been converting lists to sets, then back to lists again to get
> unique lists.

Maybe you should consider whether its best to work with sets only and
not use lists at all.
This needs to be said because:
1. Most intros to python show lists (and tuples which is almost the
same) and hardly mention sets
2. Until recent versions python did not have sets

The basic question to ask yourself is: Is order/repetition
significant?
If not you want a set.



More information about the Python-list mailing list