On Tue, Oct 12, 2021 at 11:50:27PM -0000, Jeremiah Vivian wrote:

> I posted a previous thread about overloading the unary `+` operator in 
> strings with `ord`, and that expanded to more than just the unary `+` 
> operator. So I'm saying now, there should be these implementations:

Did you actually read people's comments in that other thread? If you did 
read that thread, you should have understood that before anyone takes 
your proposal seriously, you **must** justify why the unary operators 
should do what you want them to do.

So far, you have suggested:

    +"s" == ord("s")
    +string = int(string)
    +string = string.lstrip()

with no justification for any of these beyond an *assumption* that 
calling the function ord() might be slower than using a unary operator. 
(That might be true, maybe, but I doubt it would be significantly 
slower.)

The point of my earlier email was to make it clear to you how random and 
arbitrary the choice of ord() for unary plus was, not to convince you to 
choose a different random and arbitrary choice.

What part of `+string` do you think CLEARLY and OBVIOUSLY means "convert 
the string to an int? Why would `-string` mean "convert to an int using 
octal" and `~string` mean base 16? Why not the other way?

Why map `+string` to lstrip() and `-string` to rstrip() instead of the 
other way? All these choices seem random and arbitrary.

You have still not posted any solid justification for why strings should 
support unary operators. You haven't even said "because I'm lazy and 
don't want to type a function name". At least that would be a reason. A 
bad reason, but still better than no reason at all.

So let me be completely frank:

- I think you have zero chance of this proposal being accepted.

- But if you were to have *any* chance at all, even one in a hundred 
  million, you need to start by giving some good reasons why unary
  operators should be used for strings at all.

- You need to justify the choices. What part of `~string` will make the 
  average Python programmer think of converting to an int in hex, or 
  striping whitespace?

-- 
Steve
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/MBKJQ75VV2QORBKPCYODRRCIJ5RAVQY4/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to