On Wed, Oct 13, 2021 at 12:05:35AM -0000, MarylandBall Productions wrote:

> I would think `~string` could be good for a shorthand way to convert a 
> string to an integer, considering you’re “inverting” the string to 
> another type

How is `int(string, 16)` "inverting"?

Inverting means to flip or reverse, not to convert to another type. Even 
if it did, why convert to an int, rather than a float, or a list, or 
bytes, or any other type?

You could maybe make an argument for ~"Hello" to invert it by reversing 
horizontally "olleH" but even that would be pretty weak.

> ~string will be a confusing operation to many users.

I think it would be *all* users. I doubt that anyone could predict that 
the ~ operator converts to int using base 16 just by looking at the 
expression in isolation.

-- 
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/37NB6VW37OS4FBJ2EDG6XTJNCI6S6B53/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to