Why this apparent assymetry in set operations?

Colin J. Williams cjw at sympatico.ca
Wed Jan 16 08:14:15 EST 2008


Steven D'Aprano wrote:
> 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 |+ ?
> 
> 
Thanks, keyboard error.

Colin W.




More information about the Python-list mailing list