[Python-ideas] universal set object for use in set manipulation

Mark Dickinson dickinsm at gmail.com
Thu Jul 23 10:39:02 CEST 2009


On Thu, Jul 23, 2009 at 7:28 AM, Andy Kish<agkish at gmail.com> wrote:
> Hi all,
>
> I think the addition of a universal set object would be a nice touch
> for python sets. Manipulation of collections of sets becomes much
> easier with it. [...]

What would set.universal() - {1, 2, 3}  return?  Would this be a
ValueError, or would you want to also implement all cofinite sets?

How would  'for x in set.universal()' behave?

What's len(set.universal())?

It seems to me that set.universal() can't be a full-fledged Python
set, so it would have to be something else.  And then

  x = set.universal().intersection(*sets)

will sometimes be returning a true set (i.e., when sets is nonempty),
and sometimes the reduced-functionality set.universal().  In many
cases you're still going to need to distinguish before doing anything
with x.

Not-all-binary-operations-have-to-have-an-identity-ly yours,

--
Mark



More information about the Python-ideas mailing list