Set and {} comparison confusion

Heiko Wundram heikowu at ceosg.de
Thu Sep 9 12:22:51 CEST 2004


Am Donnerstag, 9. September 2004 10:18 schrieb Alex Martelli:
> def same_as_sets(onelist, another):
>     for item in onelist:
>         if item in another: return False
>     for item in another:
>         if item in onelist: return False
>     return True

Minor correction, shouldn't this be:

for item in onelist:
  if item not in another: return False
...

Notice the nice little word not, which makes all the difference... ;)

Heiko.



More information about the Python-list mailing list