operators and datatypes for sets

Alex Martelli aleaxit at yahoo.com
Tue Apr 24 10:24:18 EDT 2001


"Anton Vredegoor" <a.vredegoor at hccnet.nl> wrote in message
news:9c3v5i$k7o$1 at news.hccnet.nl...
    [snip]
> Its a bit confusing, I agree. But just imagine having to program a lot
> of set operations like:
>
>  if s1 in s2:
> dosomething()
>  else:
> dosomethingelse()
>
> Doesn't it feel right? :-)

Not to this reader.  I would rather expect from this that
s2 is a set that may contain other sets as members, and
that the code is testing to see whether set s1 is such a
set-member of s2.

If any language-specific operator syntax was being extended
to test for "is-subset-of", I would expect to use < and <=
(look like the normal math notation for proper-subclass and
subclass, which do define a partial order).  But I think
s2.has_subset(s1) and.or s1.is_subset_of(s2) might be more
readable and less accident-prone.


Alex






More information about the Python-list mailing list