[Python-ideas] universal set object for use in set manipulation
Andrew Bennetts
andrew at bemusement.org
Thu Jul 23 12:19:03 CEST 2009
Andy Kish wrote:
> If we want to go golfing :), my favorite solution is with the python
> 2.6 versions of intersection and union:
>
> set_union = set().union(*sets)
> set_intersection = set.universal().intersection(*sets)
>
> Folds are nice. That's actually why I sent my initial email to the
> list. It's really annoying to having appropriate identity element for
> union built in while missing the *correct* identity element for
> intersection.
Well, not that my opinion counts for much, I'm +0 on it. It's conceptually nice
as you say, but I doubt I (or many others) would use it much, and hanging it off
the set builtin doesn't feel totally satisfactory to me (but I don't have a
better suggestion).
I hope you find some more firmly opinionated responses to your idea. :)
-Andrew.
More information about the Python-ideas
mailing list