[issue35338] set union/intersection/difference could accept zero arguments

Mark Dickinson report at bugs.python.org
Thu Nov 29 13:31:25 EST 2018


Mark Dickinson <dickinsm at gmail.com> added the comment:

> The intersection of an empty set of sets is either the empty set [...]

Nope, it's never the empty set, unless you're using a *very* unusual definition.

The intersection of a collection X of sets is the set of all x in the universe such that x is in S for all S in X. If X is empty, that condition is vacuously true, and you simply get the set of all x.

There are universe problems here, but giving the empty set is definitely wrong.

OTOH, the union of an empty collection of sets _is_ unambiguously the empty set, and the request for `set.union(*args)` to be valid regardless of the length of args seems reasonable to me. Without that validity, there's a potential corner-case bug where `set.union(*args)` potentially fails when `args` is empty.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35338>
_______________________________________


More information about the Python-bugs-list mailing list