Why this apparent assymetry in set operations?
mr.cerutti at gmail.com
Tue Jan 15 19:25:27 CET 2008
On Jan 15, 2008 12:06 PM, Chris M <chris.monsanto at gmail.com> wrote:
> On Jan 15, 11:51 am, "Neil Cerutti" <mr.ceru... at gmail.com> wrote:
> > So this is a bug in set_update or in set_ior. They can't both be
> > right.
> It's not a bug.
> "Note, the non-operator versions of union(), intersection(),
> difference(), and symmetric_difference(), issubset(), and issuperset()
> methods will accept any iterable as an argument. In contrast, their
> operator based counterparts require their arguments to be sets. This
> precludes error-prone constructions like set('abc') & 'cbs' in favor
> of the more readable set('abc').intersection('cbs')."
Thanks. That neatly answers Skip's question, assuming he buys the
putative error pronicity. The docs say the design is based on lessons
learned from the sets module, so that also explains why it's different
from the module version, as well.
Neil Cerutti <mr.cerutti+python at gmail.com>
More information about the Python-list