Why this apparent assymetry in set operations?

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Tue Jan 15 16:38:32 EST 2008


On Tue, 15 Jan 2008 11:25:25 -0500, Colin J. Williams wrote:

> I'm sorry, there appears to be a bug: # tSet.py
> import sets
> s1= sets.Set([1, 2, 3])
> s1.union_update([3, 4,5])
> print(s1)
> s2= sets.Set([6, 7, 8])
> s1 |+ s2          # This fails:
> exceptions.TypeError: bad operand type for unary +: 'Set'

And so it should fail. Did you mean |= instead of |+ ?


-- 
Steven



More information about the Python-list mailing list