On Tue, Oct 12, 2021 at 9:40 AM MRAB <python@mrabarnett.plus.com> wrote:
On 2021-10-12 13:49, Steven D'Aprano wrote:
> On Tue, Oct 12, 2021 at 11:36:42PM +1100, Chris Angelico wrote:
>
>> You haven't given any reason why unary plus should imply ord().
>
> I think the question Chris is really asking is why should unary plus
> return ord() rather than any other function or method.
>
> We could make unary plus of a string equal to the upper() method:
>
>      +"Hello world"  # returns "HELLO WORLD"
>
You could then strengthen that suggestion by saying the unary minus
would be equivalent to the lower() method.

I would "strengthen" it further by suggesting swapcase for the squiggle operator:

>>> ~"Lime Cordial Delicious"
'lIME cORDIAL dELICIOUS'

And title case for the carot:

>>> ^"lime cordial delicious"
'Lime Cordial Delicious'

So many shortcuts! Think of the line space savings.

---
Ricky.

"I've never met a Kentucky man who wasn't either thinking about going home or actually going home." - Happy Chandler