Thank you very much ! I didn't know that.
I note that this information is a bit difficult to reach in the 
documentation... and tha, in my Sage installation (from git tree, on Debian 
testing), "search_doc" is broken.
Le dimanche 16 mai 2021 à 09:51:39 UTC+2, Nils Bruin a écrit :

> If the preparser is active in sage (and it is by default if you run sage 
> in its normal, interactive way or if you use *.sage files) then the 
> substitution "^" -> "**" is made. Hence, the error message that you see: 
> python is complaining about "**" as an unsupported operand type, not "^". 
> The decision to let "^" mean exponentiation rather than "bitwise exclusive 
> or" is very intentional in sage: the notation x^2 for "x squared" is so 
> ingrained that not recognizing it would render sage unacceptable for its 
> intended mathematical target group.
>
> I don't think it's desirable to let {1,2,3} ** {1,4,5} stand for 
> "symmetric difference" of sets.
>
> If you want to access the python "^" operator with the preparser active, 
> you have to spell it as "^^". This is supported for both python sets and 
> for the sage Set :
>
> sage: Set({1,2}) ^^ Set({1,4}) 
> {2, 4} 
>
>
>
> On Saturday, May 15, 2021 at 11:09:35 PM UTC-7 emanuel.c...@gmail.com 
> wrote:
>
>> Dear list,
>>
>> consider python :
>>
>> >>> a = set(['a', 'b', 'c'])
>> >>> b = set(['b', 'c', 'd'])
>> >>> a & b
>> {'b', 'c'}
>> >>> a | b
>> {'b', 'a', 'd', 'c'}
>> >>> a - b
>> {'a'}
>> >>> a ^ b
>> {'a', 'd'}
>>
>> vs Sage :
>>
>> sage:  a = set(['a', 'b', 'c'])
>> sage:  b = set(['b', 'c', 'd'])
>> sage:  a & b
>> {'b', 'c'}
>> sage:  a | b
>> {'a', 'b', 'c', 'd'}
>> sage:  a - b
>> {'a'}
>> sage:  a ^ b
>> ---------------------------------------------------------------------------
>> TypeError                                 Traceback (most recent call last)
>> <ipython-input-10-7c22c32c86c9> in <module>
>> ----> 1 a ** b
>>
>> TypeError: unsupported operand type(s) for ** or pow(): 'set' and 'set'
>> sage:  a = Set(['a', 'b', 'c'])
>> sage:  b = Set(['b', 'c', 'd'])
>> sage:  a & b
>> {'b', 'c'}
>> sage:  a | b
>> {'d', 'b', 'c', 'a'}
>> sage:  a - b
>> {'a'}
>> sage:  a ^ b
>> ---------------------------------------------------------------------------
>> TypeError                                 Traceback (most recent call last)
>> <ipython-input-16-7c22c32c86c9> in <module>
>> ----> 1 a ** b
>>
>> TypeError: unsupported operand type(s) for ** or pow(): 
>> 'Set_object_enumerated_with_category' and 
>> 'Set_object_enumerated_with_category'
>>
>> Is the non-overloading of the ^ operator intentional (and, if so, for 
>> which reason ?) or an oversight (a. k. a. bug) ?
>>
>> Sincerely,
>> ​
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/78d6ba4d-0e3e-454d-9486-fbdd62f45694n%40googlegroups.com.

Reply via email to